Re: Using local variables and set and named selection names in a recursive situation

2018-08-29 Thread Chip Scheide via 4D_Tech
Pat,
I am less familiar with named selections...I am assuming that they 
operate in a similar manner to sets (see below).

With sets:
-$setname is a PROCESS set, and is NOT available on server
-setname is a process set + is available on server
-<>set name is an interprocess set, and (I believe) is not available on 
server
-creating "setname" on [table_one], then creating "setname" on 
[table_Two], removes from existence the set on table one -- as if it 
never existed.

in answer to your specific question- YES you need to create a new 
setname on each recursive call
you can do something like:
$Setname:="$"+tablename($Table_Pointer)
Create set($Setname)

(replace Create set with Copy named selection as needed.

Chip

On Wed, 29 Aug 2018 13:04:15 +0100, Pat Bensky via 4D_Tech wrote:
> 
> My workaround is to keep track of the iteration level and create a new set
> name for each level.
> The same thing happens with both named selections and sets.
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
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: Using local variables and set and named selection names in a recursive situation

2018-08-29 Thread John DeSoi via 4D_Tech
Hi Pat,

There is no such thing as a local named selection. That is just a named 
selection name that begins with a "$" character. A leading $ in a string has a 
meaning for a local set name, but that just means the set is only on the client 
and not the server. See 

http://doc.4d.com/4Dv17/4D/17/Named-Selections.300-3730545.en.html

which discusses both sets and named selections.

Within the scope of the process, you need to have unique names to have 
different sets or named selections. I always use a generator function rather 
than naming directly. It gives you a unique name and you can encode the table 
and other information in the name.

John DeSoi, Ph.D.





> On Aug 29, 2018, at 7:04 AM, Pat Bensky via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> create named selection(TablePtr->;"$deletes")

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

Using local variables and set and named selection names in a recursive situation

2018-08-29 Thread Pat Bensky via 4D_Tech
Using v17:

I have a method that recursively deletes records from related tables.
Something like this (vastly simplified):

// recursiveDelete
$tablenumber:=$1
$TablePtr:=table(tablenumber)
all records(TablePtr->)
create named selection(TablePtr->;"$deletes")
for($i;1;records in selection(TablePtr->))
// find related records in another table - eg table no. 2
recursiveDelete(2)
use named selection("$deletes")
next record(TablePtr->)
end for

The problem is that the named selection $deletes seems to work like a
process variable instead of a local variable. IE if on the first iteration
there are 200 records in $deletes, and on the second iteration there are 0
records in $deletes, then when it loops back to the first iteration there
are 0 records in $deletes whereas there should be 200.

Is it supposed to work like that? It isn't logical, Mr. Spock.

My workaround is to keep track of the iteration level and create a new set
name for each level.
The same thing happens with both named selections and sets.

Pat


-- 
*
CatBase - Top Dog in Data Publishing
tel: +44 (0) 207 118 7889
w: http://www.catbase.com
skype: pat.bensky
*
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**