Re: New record numbering system and CALL WORKER

2018-08-26 Thread Chuck Miller via 4D_Tech
OK i have done this many times with a table. You have multiple records in the 
table, one for each id you need. I usually make that records key name 
([table]field). If you have to keep track of released numbers, you can add a 
blob field. I would not be adding object fields as you can not access using 
SQL. I also have never figured out why you need a semaphore. I think in olden 
days (v1, 1.5 etc) you needed to slow this down to some extent.

You have be cognizant of whether you are inside a transaction or not. these 
queries and updates are blazing since you always have relatively few records in 
the table. If you have 500 keys you will have 500 records. Run method. Query 
for key. Load record if locked wait retry load. See if you have any returned 
numbers otherwise set next number, save record, unload record return it.

Pat when you say you need to use all numbers what happens in the following 
scenario. You create a record and it gets ID 100, for the next months you 
create 10,000 more records. You then decide to delete 1000, would you reuse 
that number. or only reuse if cancelling out of creation. If the later why not 
simply assign right before you save

Regards


Chuck

 Chuck Miller Voice: (617) 739-0306
 Informed Solutions, Inc. Fax: (617) 232-1064   
 mailto:cjmillerinformed-solutions.com 
 Brookline, MA 02446 USA Registered 4D Developer
   Providers of 4D and Sybase connectivity
  http://www.informed-solutions.com  

This message and any attached documents contain information which may be 
confidential, subject to privilege or exempt from disclosure under applicable 
law.  These materials are intended only for the use of the intended recipient. 
If you are not the intended recipient of this transmission, you are hereby 
notified that any distribution, disclosure, printing, copying, storage, 
modification or the taking of any action in reliance upon this transmission is 
strictly prohibited.  Delivery of this message to any person other than the 
intended recipient shall not compromise or waive such confidentiality, 
privilege or exemption from disclosure as to this communication. 

> On Aug 25, 2018, at 10:10 AM, Pat Bensky via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> Using v17 ...
> 
> I'm looking at ways to update our ancient record numbering system, and I
> think I should be able to do it efficiently with CALL WORKER, but having a
> bit of trouble getting my head around  it.
> 
> The record numbers are like invoice numbers: each must be unique, and we
> don't want to have any gaps in the numbering sequence. So we need to keep
> track of any record numbers that are created and then abandoned (eg if a
> user creates a new record and then cancels it).
> The old system works well but it uses semaphores and SET/GET PROCESS
> VARIABLE and DELAY PROCESS. I isn't very efficient, especially when a large
> number of records are being imported and each one needs a new record number.
> Record numbers must be assigned synchronously - processing must not
> continue until the new record number has been assigned. Also, this
> frequently needs to be done in a context where there is no active form, so
> CALL FORM won't work.
> 
> As I see it, we'll need to call a worker, which calls the worker that
> assigns the record number.
> The first worker has to wait until the second one has created the new
> number.
> Then the original method, that called the first worker, must wait until the
> first worker  gets the new number. It seems that this won't be much better
> than the old method.
> 
> Am I completely barking up the wrong tree? Is this not an appropriate use
> for workers? Or have I misunderstood something?
> 
> Pat

**
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
**

Writing Components

2018-08-26 Thread Jody Bevan via 4D_Tech
I really want to place a bunch of our code / forms into a component. It will 
make it much easier to install into other systems, and to update that code / 
forms as into older designed system that use an older version of the component. 
Of course it also protects what could otherwise be unprotected code.

What sources of good information are there other than 4D’s Component 
documentation in the manuals? I expect I will comb through the inug and 
Knowledge base when I run into problems. From the number of questions I see 
here, it looks like the component pitfalls are not documented well. I know as I 
started to read the documentation - within the first page they introduced a 
term ‘matrix databases’ that was not defined as to how they are using it. The 
sentence then became meaningless - hate writing like that.

It is a great concept, and has matured over the years, and many are using it 
successfully. It is past due for me to jump into that pool too.

Thanks

Jody
**
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: New record numbering system and CALL WORKER

2018-08-26 Thread John DeSoi via 4D_Tech
Storage is the best option for interprocess communications if you want to use 
preemptive processes. I have not done any real benchmarking but I have not 
noticed that anything seems slow. By setting up return values on a per-process 
basis you can avoid locking contention on storage. 

For example, I have a wrapper for CALL FORM which allows a return value. I'm 
using this to provide services to non-GUI (possibly preemptive) processes that 
need to call form related features. One place I'm using this is to call a 
Javascript auto-layout library (http://ijzerenhein.github.io/autolayout.js) to 
generate a form layout from a constraint specification. This approach allows me 
to load the layout library in one (hidden) process and use it from any other 
process. The call looks like this:


//Internal method to execute the auto layout request in the web/javascript 
process.

  //$0 - Object with layout specification.
  //$1 - Collection of VFL specification strings.
  //$2 - View with.
  //$3 - View height.
  //$4 - (flag) Layout window, provided by this method only.


C_OBJECT($0;$oResult)
C_COLLECTION($1;$cSpec)
C_LONGINT($2;$width;$3;$height)
C_LONGINT($4;$window)

$cSpec:=$1
$width:=$2
$height:=$3

If (Count parameters<4)
$window:=FD_Layout_window 
PM_CALL_IN_FORM_WINDOW (Current method 
name;->$oResult;0;->$cSpec;->$width;->$height;->$window)
Else 
WA EXECUTE JAVASCRIPT 
FUNCTION(fd_waLayout;"autoLayoutD5";$oResult;$cSpec;$width;$height)
End if 

$0:=$oResult


John DeSoi, Ph.D.



> On Aug 25, 2018, at 4:44 PM, Tim Nevels via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> But lets explore other possibilities. What could “Storage” be use for in 
> other cases? Is it a good use of “Storage”?

**
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: New record numbering system and CALL WORKER

2018-08-26 Thread Keisuke Miyako via 4D_Tech
I totally agree with Christian, in fact,
the point (slow, should be avoided if possible) was right there in the Summit 
keynote.

on the point of "slow"
of course it is a relative thing and perhaps not a big deal depending on the 
context,
but you only have to run code with Storage and the speed difference is quite 
palpable.
it is not a 4D specific phenomena, it is intrinsic to how blocking based on 
mutex works.

on the point of "good coding"
4D forces you to forfeit exclusive access with the "Use/End use" code block,
so unless you implicitly use storage in a stacked subroutine (super bad idea),
it is hard to violate the FILO tule unintentionally.

a more subtle gotcha is to make the mistake of
using objects and collections as if they were values, not references.
it's not limited to storage, but it can really bite you when you make the 
mistake with storage.

2018/08/26 17:26、Tim Nevels via 4D_Tech 
<4d_tech@lists.4d.com>のメール:

Humm... interesting comment. Why do you say Storage is slower and can produce 
deadlocks? Tell us why you believe this.



**
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: New record numbering system and CALL WORKER

2018-08-26 Thread Tim Nevels via 4D_Tech
Humm... interesting comment. Why do you say Storage is slower and can produce 
deadlocks? Tell us why you believe this. 

Was my example an example of “not well programmed”? Be honest. Give me real, 
solid,  constructive criticism. This is a forum for exchanging ideas and 
learning. I’ve been wrong many times in the past. I may be wrong now. I am 
interested in learning and improving and understanding more. 

Please elaborate on why “you should avoid Storage where you can”.  

I thought Storage was a wonderful new 4D feature. But you say it should be 
avoided. Why?

Tim

Sent from my iPad

> On Aug 26, 2018, at 3:03 AM, Christian Sakowski 
>  wrote:
> 
> Hopefully not. You should avoid Storage where you can. They are slower and 
> can produce (if not well programmed) dead locks.
**
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: New record numbering system and CALL WORKER

2018-08-26 Thread Christian Sakowski via 4D_Tech
> But lets explore other possibilities.

Hopefully not. You should avoid Storage where you can. They are slower and can 
produce (if not well programmed) dead locks.
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
christian.sakow...@heubach-media.de
iChat/AIM: SakowskiF
Tel: +49/(0)40/52 10 59-23



> Am 25.08.2018 um 23:44 schrieb Tim Nevels via 4D_Tech <4d_tech@lists.4d.com>:
> 
> On Aug 25, 2018, at 4:33 PM, Christian Sakowski 
>  wrote:
> 
>> i mainly use Storage as „constants“. I store global attributes and user 
>> specific options and access rights. Those are in fact mostly read only.
> 
> Hi Christian,
> 
> And that is a great use of “Storage”. I’ll be doing the same thing in new 
> databases I create.
> 
> But lets explore other possibilities. What could “Storage” be use for in 
> other cases? Is it a good use of “Storage”?
> 
> One of the great things about 4D is that features designed and intended to be 
> use for one situation turn out to be very useful in other situations. And I 
> love the “big brains” on the iNUG exposing these new uses.
> 
> Tim
> 
> *
> Tim Nevels
> Innovative Solutions
> 785-749-3444
> timnev...@mac.com
> *
> 
> **
> 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
> **


--
heubach media
Osterfeldstr. 12-14 | Haus 1 | Eingang Nord
22529 Hamburg
tel: 040 / 52 10 59 - 10 | fax: -99
mail: i...@heubach-media.de
home: www.heubach-media.de
Geschäftsführer|CEO: Matthias Heubach

Mieten Sie Ihre Computer, iPads & Drucker für Ihre Events bei:
http://www.milo-rental.com

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten 
haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht 
gestattet.
 
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the
material in this e-mail is strictly forbidden.
**
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
**