Re: Pointer to field using field name

2018-05-19 Thread Kirk Brooks via 4D_Tech
Yes - once more illustrating that just because we could do something does not mean we should. On Sat, May 19, 2018 at 11:58 AM Arnaud de Montard via 4D_Tech < 4d_tech@lists.4d.com> wrote: > > > Le 19 mai 2018 à 20:22, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> > a écrit : > > > > I don't even

Re: Pointer to field using field name

2018-05-19 Thread Arnaud de Montard via 4D_Tech
> Le 19 mai 2018 à 20:22, Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> a > écrit : > > I don't even know if 4D > supports tables with more than 1000 fields (probably does now) but that > just seems like incredibly - esoteric - design, at best. 2^32 is the max for fields and tables. Using sql

Re: Pointer to field using field name

2018-05-19 Thread Kirk Brooks via 4D_Tech
Miyako, I think the first iteration of this idea I came across did use bit shifting for storing the table number, as I think about it. I've adopted this approach because it's human-readible and simple. I don't even know if 4D supports tables with more than 1000 fields (probably does now) but that j

Re: Pointer to field using field name

2018-05-19 Thread Arnaud de Montard via 4D_Tech
> Le 19 mai 2018 à 09:28, Jim Dorrance via 4D_Tech <4d_tech@lists.4d.com> a > écrit : > > I use maxint because it is a constant:) Yes, in the tread under Benoit suggested something similar: • store: $combo_l:=($tableNum << 16)+$fieldNum • extract: $tableNum:=$combo_l >> 16 $fieldNum:=$com

Re: Pointer to field using field name

2018-05-19 Thread Jim Dorrance via 4D_Tech
I use maxint because it is a constant:) -- Jim Dorrance jim.dorra...@gmail.com 4...@dorrance.eu www.4d.dorrance.eu PS: If you know of anyone that needs an experienced 4D programmer to add energy and experience to their team, please let me know. I have experience in many areas. Reasonable rates.

Re: Pointer to field using field name

2018-05-18 Thread Keisuke Miyako via 4D_Tech
oops you are right! 1 would overflow the max number of tables and fields but won’t have problems with long int. ** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archi

Re: Pointer to field using field name

2018-05-18 Thread Arnaud de Montard via 4D_Tech
> Le 18 mai 2018 à 22:41, Keisuke Miyako via 4D_Tech <4d_tech@lists.4d.com> a > écrit : > > won't 10K could overflow 32-bit integer? > I would use 32768 as multiplier... Why? 2^(32-1) > 2,000,000,000 I use more: $tableAndField:=(100,000*tableNum)+fieldNum -- Arnaud *

Re: Pointer to field using field name

2018-05-18 Thread Keisuke Miyako via 4D_Tech
won't 10K could overflow 32-bit integer? I would use 32768 as multiplier... > 2018/05/19 2:03、Kirk Brooks via 4D_Tech <4d_tech@lists.4d.com> のメール: > I can't take credit for making it up and I don't recall where I got the > idea from. If you are really worried about a table with more than 1000 > fi

Re: Pointer to field using field name

2018-05-18 Thread Kirk Brooks via 4D_Tech
Alan, I'm a little late to this thread and I don't want to muddy the waters but I find working with numeric pointers to fields helpful in these instances. What's a 'numeric pointer'? I do it very simply: (table number * 1000)+field number. This yields a unique value for each field and can be manage

Re: Pointer to field using field name

2018-05-18 Thread Alan Tilson via 4D_Tech
Hello everyone and thank you for your thoughts on this, First I don't ever expect to compile our system since working on it live is a fundamental requirement of our approach, unless that changes of course... Secondly I'm actually using dynamic field names since I am using the field names from th

Re: Pointer to field using field name

2018-05-18 Thread Arnaud de Montard via 4D_Tech
> Le 17 mai 2018 à 19:24, Alan Tilson via 4D_Tech <4d_tech@lists.4d.com> a > écrit : > > [...] > Is there something wrong with this? > > EXECUTE FORMULA("$pField:=->["+tablename+"]"+fieldname) > ​ > It seems to work and it also seems like it would be fast! Not sure, it calls the interpreter wh

RE: Pointer to field using field name

2018-05-17 Thread Dennis, Neil via 4D_Tech
> $code:="$4deval($1->:=->["+$tablename+"]"+$fieldname+")" > PROCESS 4D TAGS($code;$code;->$pField) This is a nice little gem to keep in mind :) Thanks Neil -- Privacy Disclaimer: This message contains confidential information and is intended only for the named addressee. If you are no

Re: Pointer to field using field name

2018-05-17 Thread Keisuke Miyako via 4D_Tech
alternatively $tablename:="Table_1" $fieldname:="ID" $code:="$4deval($1->:=->["+$tablename+"]"+$fieldname+")" PROCESS 4D TAGS($code;$code;->$pField) EXECUTE FORMULA("$pField:=->["+tablename+"]"+fieldname) ** 4D Internet Users

Re: Pointer to field using field name

2018-05-17 Thread Tim Nevels via 4D_Tech
On May 17, 2018, at 2:00 PM, Alan Tilson wrote: > Thank you Koen, Dennis & Chip, > > I probably should have said what I was doing...which is that I'm copying > certain fields from a sister table with some of the same field names. So I > step though all the sister table fields and load the values

RE: Pointer to field using field name

2018-05-17 Thread Dennis, Neil via 4D_Tech
> It seems to work and it also seems like it would be fast! > EXECUTE FORMULA("$pField:=->["+tablename+"]"+fieldname) Unless something has changed, this will not work compiled. Neil Privacy Disclaimer: This message contains confidential information and is intended only for the named addre

Re: Pointer to field using field name

2018-05-17 Thread Alan Tilson via 4D_Tech
Thank you Koen, Dennis & Chip, I probably should have said what I was doing...which is that I'm copying certain fields from a sister table with some of the same field names. So I step though all the sister table fields and load the values (except for the first one which is the ID field) into the p

Re: Pointer to field using field name

2018-05-17 Thread Chip Scheide via 4D_Tech
that approach will break if you change the field name, assuming the field name is hardcoded. depending on your needs you can do this (code written in email so...): this code can be run as needed, at process startup (use process vars), or it can be run at database startup (use Interprocess vars)

RE: Pointer to field using field name

2018-05-17 Thread Dennis, Neil via 4D_Tech
To get a field pointer to a field from the field name you can loop through the table incrementing the field number until you find the correct name and return a pointer to it, this is very fast since it is all in memory. For ($i;1;Get last field number($TableNumber)) If (Is field number v

Re: Pointer to field using field name

2018-05-17 Thread Koen Van Hooreweghe via 4D_Tech
Hi Alan, If you have the table number, you can loop over the fields of that table and compare the name to the given name to get the field number and thus the field pointer. Something like: //$foundtable is the table number //if pointer given, $foundtable := Table($tablepointer) For ($i;1;Get

Re: Pointer to field using field name

2018-05-17 Thread Alan Tilson via 4D_Tech
currently I'm using v13.6 if that matters... Alan On Thu, May 17, 2018 at 12:19 PM, Alan Tilson wrote: > ​Hello out there, > > Is it possible to extract a pointer to a field from the table number or > pointer and the field name? > > I'm loading a field using EXECUTE FORMULA and building the > [t