Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #11276 > unrolled thread
| Started by | "Grzegorz R." <ramotny64@gmail.com> |
|---|---|
| First post | 2018-01-09 08:01 -0800 |
| Last post | 2018-01-21 03:25 -0800 |
| Articles | 7 — 4 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
Database ACCESS/ASSIGN with function "Grzegorz R." <ramotny64@gmail.com> - 2018-01-09 08:01 -0800
Re: Database ACCESS/ASSIGN with function JohnMartens <martens@tennishulp.info> - 2018-01-09 17:11 +0100
Re: Database ACCESS/ASSIGN with function Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> - 2018-01-09 17:56 +0100
Re: Database ACCESS/ASSIGN with function "Jamal" <noooospam@example.com> - 2018-01-09 13:19 -0500
Re: Database ACCESS/ASSIGN with function "Grzegorz R." <ramotny64@gmail.com> - 2018-01-09 23:23 -0800
Re: Database ACCESS/ASSIGN with function "Jamal" <noooospam@example.com> - 2018-01-10 10:29 -0500
Re: Database ACCESS/ASSIGN with function "Grzegorz R." <ramotny64@gmail.com> - 2018-01-21 03:25 -0800
| From | "Grzegorz R." <ramotny64@gmail.com> |
|---|---|
| Date | 2018-01-09 08:01 -0800 |
| Subject | Database ACCESS/ASSIGN with function |
| Message-ID | <72d34f83-34d6-4050-9e2b-d148bbed72e9@googlegroups.com> |
Hi Folks
I have a database field which has to be encoded/decoded each time it is assigned/accessed (like cypher/decypher). I have both functions and use it "within" database code like this (written by hand):
ACCESS NIP AS STRING PASCAL CLASS KLIENCI
RETURN DekodujNIP(SELF:FIELDGET(#NIP))
ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS KLIENCI
RETURN SELF:FIELDPUT(#NIP, KodujNIP(uValue))
My problem is that if I change a structure of database in IDE both functions are reset to standard ie functions are removed:
ACCESS NIP AS STRING PASCAL CLASS KLIENCI
RETURN SELF:FIELDGET(#NIP)
ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS KLIENCI
RETURN SELF:FIELDPUT(#NIP, uValue)
Of course I can use both functions in each place as use field NIP but as far as coding/decoding happens always it is wise to use it in deepest point ie database.
IF I try to defice virtual access like
ACCESS GetNIP AS STRING PASCAL CLASS KLIENCI
RETURN DekodujNIP(SELF:FIELDGET(#NIP))
I get "insuficient data for diagnostics 52999"
method like
METHOD GetNIP() AS STRING PASCAL CLASS KLIENCI
RETURN DekodujNIP(SELF:FIELDGET(#NIP))
works ok and is not destroyed at database structure change but is not as elegant as direct field operations.
Is there any way to get what I want?
Regards
Gregory
[toc] | [next] | [standalone]
| From | JohnMartens <martens@tennishulp.info> |
|---|---|
| Date | 2018-01-09 17:11 +0100 |
| Message-ID | <p32pjt$i8h$1@dont-email.me> |
| In reply to | #11276 |
Does it help if you see where to error comes from using ACCESS GetNIP AS STRING PASCAL CLASS KLIENCI LOCAL cFieldGet AS STRING LOCAL cResult AS STRING cFieldGet := SELF:FIELDGET(#NIP) cResult := DekodujNIP(cFieldGet) RETURN cResult John Op 9-1-2018 om 17:01 schreef Grzegorz R.: > Hi Folks > > I have a database field which has to be encoded/decoded each time it is assigned/accessed (like cypher/decypher). I have both functions and use it "within" database code like this (written by hand): > > ACCESS NIP AS STRING PASCAL CLASS KLIENCI > RETURN DekodujNIP(SELF:FIELDGET(#NIP)) > > ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS KLIENCI > RETURN SELF:FIELDPUT(#NIP, KodujNIP(uValue)) > > My problem is that if I change a structure of database in IDE both functions are reset to standard ie functions are removed: > > ACCESS NIP AS STRING PASCAL CLASS KLIENCI > RETURN SELF:FIELDGET(#NIP) > > ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS KLIENCI > RETURN SELF:FIELDPUT(#NIP, uValue) > > Of course I can use both functions in each place as use field NIP but as far as coding/decoding happens always it is wise to use it in deepest point ie database. > > IF I try to defice virtual access like > > ACCESS GetNIP AS STRING PASCAL CLASS KLIENCI > RETURN DekodujNIP(SELF:FIELDGET(#NIP)) > > I get "insuficient data for diagnostics 52999" > > method like > > METHOD GetNIP() AS STRING PASCAL CLASS KLIENCI > RETURN DekodujNIP(SELF:FIELDGET(#NIP)) > > works ok and is not destroyed at database structure change but is not as elegant as direct field operations. > > Is there any way to get what I want? > > Regards > Gregory >
[toc] | [prev] | [next] | [standalone]
| From | Karl Faller <mail_withoutthat_@_drei-f_andthat_.de> |
|---|---|
| Date | 2018-01-09 17:56 +0100 |
| Message-ID | <e0t95dhqoio31n35eu1d7rsjcsjmafg6ob@4ax.com> |
| In reply to | #11276 |
Grzegorz, did you try to set "No Access/Assign" in DB-Editor from Auto to "false"? Karl >Hi Folks > >I have a database field which has to be encoded/decoded each time it is assigned/accessed (like cypher/decypher). I have both functions and use it "within" database code like this (written by hand): > >ACCESS NIP AS STRING PASCAL CLASS KLIENCI > RETURN DekodujNIP(SELF:FIELDGET(#NIP)) > >ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS KLIENCI > RETURN SELF:FIELDPUT(#NIP, KodujNIP(uValue)) > >My problem is that if I change a structure of database in IDE both functions are reset to standard ie functions are removed: > >ACCESS NIP AS STRING PASCAL CLASS KLIENCI > RETURN SELF:FIELDGET(#NIP) > >ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS KLIENCI > RETURN SELF:FIELDPUT(#NIP, uValue) > >Of course I can use both functions in each place as use field NIP but as far as coding/decoding happens always it is wise to use it in deepest point ie database. > >IF I try to defice virtual access like > >ACCESS GetNIP AS STRING PASCAL CLASS KLIENCI > RETURN DekodujNIP(SELF:FIELDGET(#NIP)) > >I get "insuficient data for diagnostics 52999" > >method like > >METHOD GetNIP() AS STRING PASCAL CLASS KLIENCI > RETURN DekodujNIP(SELF:FIELDGET(#NIP)) > >works ok and is not destroyed at database structure change but is not as elegant as direct field operations. > >Is there any way to get what I want? > >Regards >Gregory Regards Karl
[toc] | [prev] | [next] | [standalone]
| From | "Jamal" <noooospam@example.com> |
|---|---|
| Date | 2018-01-09 13:19 -0500 |
| Message-ID | <p3312m$tab$1@news.albasani.net> |
| In reply to | #11276 |
Besides the other ideas and to reduce amount of generated code and instead
of creating assigns and accesses for all fields, I would subclass the
dbServer class and create my own FIELDGET() and FIELDPUT() methods.
For example:
CLASS MyNIPDBServer INHERIT DBServer
Method Init(.....) CLASS MyNIPDBServer
// init code
RETURN SELF
METHOD FieldGet(uField) CLASS MyNIPDBServer
RETURN DekodujNIP(SELF:FIELDGET(uField))
METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
RETURN SELF:FIELDPUT(uField, KodujNIP(uValue))
Jamal
"Grzegorz R." wrote in message
news:72d34f83-34d6-4050-9e2b-d148bbed72e9@googlegroups.com...
Hi Folks
I have a database field which has to be encoded/decoded each time it is
assigned/accessed (like cypher/decypher). I have both functions and use it
"within" database code like this (written by hand):
ACCESS NIP AS STRING PASCAL CLASS KLIENCI
RETURN DekodujNIP(SELF:FIELDGET(#NIP))
ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS KLIENCI
RETURN SELF:FIELDPUT(#NIP, KodujNIP(uValue))
My problem is that if I change a structure of database in IDE both functions
are reset to standard ie functions are removed:
ACCESS NIP AS STRING PASCAL CLASS KLIENCI
RETURN SELF:FIELDGET(#NIP)
ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS KLIENCI
RETURN SELF:FIELDPUT(#NIP, uValue)
Of course I can use both functions in each place as use field NIP but as far
as coding/decoding happens always it is wise to use it in deepest point ie
database.
IF I try to defice virtual access like
ACCESS GetNIP AS STRING PASCAL CLASS KLIENCI
RETURN DekodujNIP(SELF:FIELDGET(#NIP))
I get "insuficient data for diagnostics 52999"
method like
METHOD GetNIP() AS STRING PASCAL CLASS KLIENCI
RETURN DekodujNIP(SELF:FIELDGET(#NIP))
works ok and is not destroyed at database structure change but is not as
elegant as direct field operations.
Is there any way to get what I want?
Regards
Gregory
[toc] | [prev] | [next] | [standalone]
| From | "Grzegorz R." <ramotny64@gmail.com> |
|---|---|
| Date | 2018-01-09 23:23 -0800 |
| Message-ID | <0bf26617-e04e-49b6-9b33-f9d2216674a5@googlegroups.com> |
| In reply to | #11279 |
@Karl
W dniu wtorek, 9 stycznia 2018 17:56:27 UTC+1 użytkownik Karl Faller napisał:
> Grzegorz,
> did you try to set "No Access/Assign" in DB-Editor from Auto to
> "false"?
>
> Karl
>
Hi Karl - this does not help because all references to this database got destroyed.
@Jamal
W dniu wtorek, 9 stycznia 2018 19:19:04 UTC+1 użytkownik Jamal napisał:
> Besides the other ideas and to reduce amount of generated code and instead
> of creating assigns and accesses for all fields, I would subclass the
> dbServer class and create my own FIELDGET() and FIELDPUT() methods.
>
> For example:
>
> CLASS MyNIPDBServer INHERIT DBServer
>
> Method Init(.....) CLASS MyNIPDBServer
> // init code
> RETURN SELF
>
> METHOD FieldGet(uField) CLASS MyNIPDBServer
>
> RETURN DekodujNIP(SELF:FIELDGET(uField))
>
> METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
>
> RETURN SELF:FIELDPUT(uField, KodujNIP(uValue))
>
> Jamal
Hi Jamal
this does not help because the database conatins also other fields not only NIP field.
My db server is already inherited (I implemented automatic db build if not exist and structure IDE-vs-File check).
The only chance with above is to include fieldname test like this:
METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
IF AsSymbol(uField)==#NIP
RETURN SELF:FIELDPUT(uField, KodujNIP(uValue))
ELSE
RETURN SELF:FIELDPUT(uField, uValue)
What You think?
Regards
Gregory
[toc] | [prev] | [next] | [standalone]
| From | "Jamal" <noooospam@example.com> |
|---|---|
| Date | 2018-01-10 10:29 -0500 |
| Message-ID | <p35bh0$utv$1@news.albasani.net> |
| In reply to | #11280 |
If that works, go for it. The FieldGet() and FieldPut() just encapsulate the
code within and you can have any code within to manipulate the values.
Note: you need to call SUPER methods to avoid an endless recursive loop,
i.e. do this:
METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
IF AsSymbol(uField)==#NIP
RETURN SUPER:FIELDPUT(uField, KodujNIP(uValue))
ELSE
RETURN SUPER:FIELDPUT(uField, uValue)
Jamal
"Grzegorz R." wrote in message
news:0bf26617-e04e-49b6-9b33-f9d2216674a5@googlegroups.com...
@Karl
W dniu wtorek, 9 stycznia 2018 17:56:27 UTC+1 użytkownik Karl Faller
napisał:
> Grzegorz,
> did you try to set "No Access/Assign" in DB-Editor from Auto to
> "false"?
>
> Karl
>
Hi Karl - this does not help because all references to this database got
destroyed.
@Jamal
W dniu wtorek, 9 stycznia 2018 19:19:04 UTC+1 użytkownik Jamal napisał:
> Besides the other ideas and to reduce amount of generated code and instead
> of creating assigns and accesses for all fields, I would subclass the
> dbServer class and create my own FIELDGET() and FIELDPUT() methods.
>
> For example:
>
> CLASS MyNIPDBServer INHERIT DBServer
>
> Method Init(.....) CLASS MyNIPDBServer
> // init code
> RETURN SELF
>
> METHOD FieldGet(uField) CLASS MyNIPDBServer
>
> RETURN DekodujNIP(SELF:FIELDGET(uField))
>
> METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
>
> RETURN SELF:FIELDPUT(uField, KodujNIP(uValue))
>
> Jamal
Hi Jamal
this does not help because the database conatins also other fields not only
NIP field.
My db server is already inherited (I implemented automatic db build if not
exist and structure IDE-vs-File check).
The only chance with above is to include fieldname test like this:
METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
IF AsSymbol(uField)==#NIP
RETURN SELF:FIELDPUT(uField, KodujNIP(uValue))
ELSE
RETURN SELF:FIELDPUT(uField, uValue)
What You think?
Regards
Gregory
[toc] | [prev] | [next] | [standalone]
| From | "Grzegorz R." <ramotny64@gmail.com> |
|---|---|
| Date | 2018-01-21 03:25 -0800 |
| Message-ID | <761d34a7-40e3-4ead-b849-8958df25f5d6@googlegroups.com> |
| In reply to | #11282 |
W dniu środa, 10 stycznia 2018 16:29:37 UTC+1 użytkownik Jamal napisał:
> If that works, go for it. The FieldGet() and FieldPut() just encapsulate the
> code within and you can have any code within to manipulate the values.
>
> Note: you need to call SUPER methods to avoid an endless recursive loop,
> i.e. do this:
>
> METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
> IF AsSymbol(uField)==#NIP
> RETURN SUPER:FIELDPUT(uField, KodujNIP(uValue))
> ELSE
> RETURN SUPER:FIELDPUT(uField, uValue)
>
>
> Jamal
>
> "Grzegorz R." wrote in message
>
> @Karl
>
> W dniu wtorek, 9 stycznia 2018 17:56:27 UTC+1 użytkownik Karl Faller
> napisał:
> > Grzegorz,
> > did you try to set "No Access/Assign" in DB-Editor from Auto to
> > "false"?
> >
> > Karl
> >
> Hi Karl - this does not help because all references to this database got
> destroyed.
>
>
> @Jamal
>
> W dniu wtorek, 9 stycznia 2018 19:19:04 UTC+1 użytkownik Jamal napisał:
> > Besides the other ideas and to reduce amount of generated code and instead
> > of creating assigns and accesses for all fields, I would subclass the
> > dbServer class and create my own FIELDGET() and FIELDPUT() methods.
> >
> > For example:
> >
> > CLASS MyNIPDBServer INHERIT DBServer
> >
> > Method Init(.....) CLASS MyNIPDBServer
> > // init code
> > RETURN SELF
> >
> > METHOD FieldGet(uField) CLASS MyNIPDBServer
> >
> > RETURN DekodujNIP(SELF:FIELDGET(uField))
> >
> > METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
> >
> > RETURN SELF:FIELDPUT(uField, KodujNIP(uValue))
> >
> > Jamal
>
> Hi Jamal
> this does not help because the database conatins also other fields not only
> NIP field.
> My db server is already inherited (I implemented automatic db build if not
> exist and structure IDE-vs-File check).
> The only chance with above is to include fieldname test like this:
>
> METHOD FieldPut(uField, uValue) CLASS MyNIPDBServer
> IF AsSymbol(uField)==#NIP
> RETURN SELF:FIELDPUT(uField, KodujNIP(uValue))
> ELSE
> RETURN SELF:FIELDPUT(uField, uValue)
>
> What You think?
>
> Regards
> Gregory
Hi Jamal
Works generally OK however NOT with bBrowser because bBrowser refers to field position rather than symbol name even if used as bDatColumn{, …, „Fieldname”,#FIELD}.
But... looking for some other things I've found a way to achieve what I wanted
Classes before mod:
DBSserver → MyDBServer → Customers
"MyDBServer" class (for all my databases) has my function of automatic self-rebuiliding/reindexing databases and I could put here Your
„Customers” has NIP field
If I use:
>METHOD FieldPut(uField, uValue) CLASS MyDBServer
> IF AsSymbol(uField)==#NIP
> RETURN SELF:FIELDPUT(uField, KodujNIP(uValue))
> ELSE
> RETURN SELF:FIELDPUT(uField, uValue)
> ENDIF
this IF-check happens for ALL fields in ALL subclassed databases which is not needed AND what more important – does NOT work with bBrowser.
So I made a different approach - additional subclass:
DBSserver → MyDBServer → Customers → NIPCustomers
where „Customers” is a real database and „NIPCustomers” has modified NIP access/assign
CLASS NIPCustomers INHERIT Customers
ACCESS NIP AS STRING PASCAL CLASS NIPCustomers
RETURN DekodujNIP(SELF:FIELDGET(#NIP))
ASSIGN NIP(uValue AS STRING) AS STRING PASCAL CLASS NIPCustomers
RETURN SELF:FIELDPUT(#NIP, KodujNIP(uValue))
Now when I use:
NIPCustomers:NIP the field gets de/coded as I wanted and I still can recompile (change) Customers database entity without destroying de/coding code again and again.
The only disadvantage is that I it requires to replace "Customer" with inherited NIPCustomer in whole code...
but...
Finally I made the subclassing the opposite way - changed database entity name „Customers” to „Cust” (real file is still Customers.dbf) and inherited it by „virtual” database „Customers” which is referred everywhere
DBSserver → MyDBServer → Cust → Customers
this eliminates all "Search-and-Replace" work in whole code but needed some database classes renaming/rebuilding just once.
Thank You very much for Your (all of You) help
Best regards
Gregory
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web