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 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 we could create that monster   ;-)

 --
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 we could create that monster   ;-)

-- 
Arnaud de Montard 




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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
just seems like incredibly - esoteric - design, at best.

On Fri, May 18, 2018 at 1:43 PM Keisuke Miyako via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> 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
> > fields use 10k as the multiplier.
>
>
>
>
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **



-- 
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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:=$combo_l & 0x

Theoretically, it suits better 4D tables and fields max. Practically, I prefer 
decimal offset 10^5 (a constant actually), it's easier to me in debug - and 
these max are so far away… 

-- 
Arnaud de Montard 



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.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. Remote or Paris only.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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
> fields use 10k as the multiplier.




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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
managed with 3 or 4 simple methods. I refer to the value as a 'fieldCode'.
  fieldCode = (table number * 1000)+field number
  table number = fieldCode\1000  //  longint division
  field number = fieldCode%1000
  fieldPointer = Field(fieldCode\1000; fieldCode%1000)

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
fields use 10k as the multiplier.

This eliminates the worry about breaking code because a name changes while
retaining an easy way to identify them. There's no tremendous downside to
storing them as text, btw. It also means you can represent an entire
structure in a single longint array.

On Fri, May 18, 2018 at 7:05 AM Alan Tilson via 4D_Tech <
4d_tech@lists.4d.com> wrote:

>  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 the sister table which are by design exactly the same as their
> sister field in the primary table. So I am taking the field name from the
> sister table and creating a pointer to it's sister (or twin?) field in the
> primary table. As long as I keep both field names the same it should work.
>
> Hard coding the link between the various pairs would certainly work and
> should be the fastest. However, in this case I'm rather attached to my
> generic code where the only thing I have to do to add a field to the
> mirroring is to add it to the sister table.
>
-- 
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 the sister table which are by design exactly the same as their
sister field in the primary table. So I am taking the field name from the
sister table and creating a pointer to it's sister (or twin?) field in the
primary table. As long as I keep both field names the same it should work.

Hard coding the link between the various pairs would certainly work and
should be the fastest. However, in this case I'm rather attached to my
generic code where the only thing I have to do to add a field to the
mirroring is to add it to the sister table.

If I can find time today I'll play with the various ideas a bit to see if
there is a speed difference and I may also use a process variable.
Currently I'm actually using $0: "EXECUTE
FORMULA("$0:=->"+$tablefieldname)". But tomorrow I'm heading out of town
for a couple of weeks so the crunch is on!

Cheers,
Alan


On Fri, May 18, 2018 at 7:32 AM, Arnaud de Montard via 4D_Tech <
4d_tech@lists.4d.com> wrote:

>
> > 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 while a loop does not. Mostly, as Neil
> said, it will fail in compiled mode as EXECUTE FORMULA does not work with
> $local variables:
> 
>
> In your situation, I'd use any mentioned trick (execute formula, loop
> through fields…) to generate hardcode to paste, something like this:
>   ++
>   $code:=""
>   for($i;1;$fieldCount)
> $source:=getFieldName(table1;$i)
> $target:=getFieldByName(table2;$source)
> $code:=$code+$target+":="+$source+"\r"
>   end for
>   set text to pasteboard($code)  //then paste in the method…
>   ++
> No hidden fields references, surely the fastest.
>
> --
> Arnaud de Montard
>
>
>
>
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
>
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 while a loop does not. Mostly, as Neil said, 
it will fail in compiled mode as EXECUTE FORMULA does not work with $local 
variables:


In your situation, I'd use any mentioned trick (execute formula, loop through 
fields…) to generate hardcode to paste, something like this:
  ++
  $code:=""
  for($i;1;$fieldCount)
$source:=getFieldName(table1;$i)
$target:=getFieldByName(table2;$source)
$code:=$code+$target+":="+$source+"\r"
  end for
  set text to pasteboard($code)  //then paste in the method… 
  ++
No hidden fields references, surely the fastest. 

-- 
Arnaud de Montard 




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 not the named addressee you 
should not disseminate, distribute or copy this email. Please delete this email 
from your system and notify the sender immediately by replying to this email.  
If you are not the intended recipient you are notified that disclosing, 
copying, distributing or taking any action in reliance on the contents of this 
information is strictly prohibited.

The Alternative Investments division of UMB Fund Services provides a full range 
of services to hedge funds, funds of funds and private equity funds.  Any tax 
advice in this communication is not intended to be used, and cannot be used, by 
a client or any other person or entity for the purpose of (a) avoiding 
penalties that may be imposed on any taxpayer or (b) promoting, marketing, or 
recommending to another party any matter addressed herein.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 (except for the
> first one which is the ID field) into the primary field. So I hate to look
> through all the field names looking for the one I'm to fill even though it
> probably is fast enough.
> 
> Loading the info into arrays seems like a step in the right direction. But
> I just thought of another idea...using EXECUTE FORMULA to load the pointer
> rather than to use the field value.
> 
> Is there something wrong with this?
> 
> EXECUTE FORMULA("$pField:=->["+tablename+"]"+fieldname)
> 
> It seems to work and it also seems like it would be fast!

Yes this works, but it could have an issue when running compiled by using a 
local variable. Might be more “safe” to use “pField” instead of “$pField” for 
the variable name. 

Also this approach is a bit brittle because it relies on a hard coded table 
name and field name. Change either and this code will fail. That is the 
advantage of referencing tables and fields by number. Never a problem with 
changing the name. 

Tim

*
Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com
*

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 addressee. If you are not the named addressee you 
should not disseminate, distribute or copy this email. Please delete this email 
from your system and notify the sender immediately by replying to this email.  
If you are not the intended recipient you are notified that disclosing, 
copying, distributing or taking any action in reliance on the contents of this 
information is strictly prohibited.

The Alternative Investments division of UMB Fund Services provides a full range 
of services to hedge funds, funds of funds and private equity funds.  Any tax 
advice in this communication is not intended to be used, and cannot be used, by 
a client or any other person or entity for the purpose of (a) avoiding 
penalties that may be imposed on any taxpayer or (b) promoting, marketing, or 
recommending to another party any matter addressed herein.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 primary field. So I hate to look
through all the field names looking for the one I'm to fill even though it
probably is fast enough.

Loading the info into arrays seems like a step in the right direction. But
I just thought of another idea...using EXECUTE FORMULA to load the pointer
rather than to use the field value.

Is there something wrong with this?

EXECUTE FORMULA("$pField:=->["+tablename+"]"+fieldname)

​
It seems to work and it also seems like it would be fast!

Alan​


On Thu, May 17, 2018 at 12:49 PM, Chip Scheide <4d_o...@pghrepository.org>
wrote:

> 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)
>
> $Table_number:=table(->[table])
> $Field_Count:=get last field number(->[table])
>
> array text($Field_Names;$field_Count)
> array pointer($Field_ptr;$Field_Count)
> array longint($Field_Number;$Field_Count)
>
> for($i;1;$Field_Count)
>
>   if (is field number valid($table_number;$i))
> $Field_Names{$i}:=field name($Table_number;$i)
> $Field_ptr{$i}:=FIeld($Table_number;$i)
> $Field_Number{$i}:=$i
>   end if
> end for
>
>
> Then where you need to get the pointer
> $loc:=find in array($Field_Names;$Field_name_to_lookup)
>
> if($loc>0)
>   $Specific_field_Pointer:=$Field_ptr{$loc}
> end if
>
>
> On Thu, 17 May 2018 12:19:11 -0400, Alan Tilson via 4D_Tech 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
> > [tablename]fieldname into the formula, which serves my purposes but seems
> > rather awkward!
> >
> > Thanks,
> > Alan ​
> > **
> > 4D Internet Users Group (4D iNUG)
> > FAQ:  http://lists.4d.com/faqnug.html
> > Archive:  http://lists.4d.com/archives.html
> > Options: https://lists.4d.com/mailman/options/4d_tech
> > Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> > **
> ---
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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)
 
$Table_number:=table(->[table])
$Field_Count:=get last field number(->[table])

array text($Field_Names;$field_Count)
array pointer($Field_ptr;$Field_Count)
array longint($Field_Number;$Field_Count)

for($i;1;$Field_Count)
  
  if (is field number valid($table_number;$i))
$Field_Names{$i}:=field name($Table_number;$i)
$Field_ptr{$i}:=FIeld($Table_number;$i)
$Field_Number{$i}:=$i
  end if
end for


Then where you need to get the pointer
$loc:=find in array($Field_Names;$Field_name_to_lookup)
  
if($loc>0)
  $Specific_field_Pointer:=$Field_ptr{$loc}
end if


On Thu, 17 May 2018 12:19:11 -0400, Alan Tilson via 4D_Tech 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
> [tablename]fieldname into the formula, which serves my purposes but seems
> rather awkward!
> 
> Thanks,
> Alan ​
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 valid($TableNumber;$i))
If (Field name($TableNumber;$i)=$TestFieldName)
$PointerToField:=Field($TableNumber;$i)
$i:=Get last field number
End if 
End if 
End for 

If you use this a lot you can use a cache array to store the pointers and field 
names, but like I said this runs very fast.


Neil



Privacy Disclaimer: This message contains confidential information and is 
intended only for the named addressee. If you are not the named addressee you 
should not disseminate, distribute or copy this email. Please delete this email 
from your system and notify the sender immediately by replying to this email.  
If you are not the intended recipient you are notified that disclosing, 
copying, distributing or taking any action in reliance on the contents of this 
information is strictly prohibited.

The Alternative Investments division of UMB Fund Services provides a full range 
of services to hedge funds, funds of funds and private equity funds.  Any tax 
advice in this communication is not intended to be used, and cannot be used, by 
a client or any other person or entity for the purpose of (a) avoiding 
penalties that may be imposed on any taxpayer or (b) promoting, marketing, or 
recommending to another party any matter addressed herein.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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 last field number($foundtable))
If (Is field number valid($foundtable;$i))
If ($fieldname=Field name($foundtable;$i))
$foundfield:=$i//found it
$i:=Get last field number($foundtable)+1//jump out of 
loop
End if 
End if 
End for 

$ptr:=Field($foundtable;$foundfield)//get the pointer

HTH
Koen

> Op 17 mei 2018, om 18:19 heeft Alan Tilson via 4D_Tech <4d_tech@lists.4d.com> 
> het volgende geschreven:
> 
> 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
> [tablename]fieldname into the formula, which serves my purposes but seems
> rather awkward!
> 

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

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
> [tablename]fieldname into the formula, which serves my purposes but seems
> rather awkward!
>
> Thanks,
> Alan ​
>
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**