Re: Creating a form object to use as dynamic form

2018-09-24 Thread Jody Bevan via 4D_Tech
Sorry Rudy, not an answer to your question, but topical I think.

Being able to create a sophisticated form via code is a fantastic feature. It 
is like the coding I did back in 1982/1983. Back when I first got my hands on 
my own copy of 4D version 2.0.10  the Graphical form editor was such a 
liberating way of creating forms, compared to the way I needed to do it in 
Pascal.

This really is a great feature, but my hope is that this is just a necessary 
1st step to being able to create a form using the normal 4D Form Editor, Form 
Method, Object Methods and then be able to save them as ‘text’ that can then be 
sent to clients.

We have often had the need to send multiple forms to different clients for them 
to run.  Then the client needs / forced to (by regulations) have a new version 
of the form. That is great, but they still have lots of data that they collect 
via the old form and need to be able to display that data in the form they used 
at the time. 

In the last major application we did, we have ~ 10,000 forms with each client 
having about 150 of them. Each client though would have a different set of 
forms. When 4D announced this feature I hoped that it will lead to fulfilling 
this need. Then as 4D developers we can provide a rich, consistent interface 
within the product rather than having to resort to forms in WebAreas, PDFs, 
etc. This will help us 4D developers stick within our expertise of 4D and be 
more productive.

Jody Bevan
Argus Development Inc.


> On Sep 24, 2018, at 8:44 AM, Two Way Communications via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> I can’t figure out how to do this … 
> 
> Using a dynamic form, I am trying to build a generic list of records to 
> display to the user and to allow him to select 1 record.
> 
> I used the example from the tech note on how to create a dynamic form that 
> shows a listbox.
> 
> To build this $form object variable, the commands New object and others are 
> used.
> 
> This listbox object is added to the $page object in the $form object, which 
> will be used in the DIALOG command.
> 
> 
> $obj:=New object("type";"listbox";"listboxType";"collection";\ 
> "dataSource";$colName;"left";0;"top";0;"width";$width+15;"height";$height)
> 
> 
> 
> $page:=New object("objects";New object("myListBox";$obj)) $form:=New 
> object(“pages";New collection(Null;$page))
> 
> $form:=New object("windowTitle";"Select a 
> Map:";"windowMinWidth";500;"windowMinHeight";300;"pages";New 
> collection(Null;$page))
> 
> Now, this dynamic form only shows a listbox, and I want to add a button to 
> the form. I assume this button object has to be added to the ‘Objects’ object 
> in $page.
> 
> But, how do I do that? I tried object arrays and collections, but neither of 
> them produces the correct result. 
> 
> 
> Secondly, the listbox displays an entity selection. How do I get the row 
> number that has been selected?
> 
> 
> 
> Regards,
> 
> Rudy Mortier
> Two Way Communications bvba 
> 

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

Creating a form object to use as dynamic form

2018-09-24 Thread Two Way Communications via 4D_Tech
I can’t figure out how to do this … 

Using a dynamic form, I am trying to build a generic list of records to display 
to the user and to allow him to select 1 record.

I used the example from the tech note on how to create a dynamic form that 
shows a listbox.

To build this $form object variable, the commands New object and others are 
used.

This listbox object is added to the $page object in the $form object, which 
will be used in the DIALOG command.


$obj:=New object("type";"listbox";"listboxType";"collection";\ 
"dataSource";$colName;"left";0;"top";0;"width";$width+15;"height";$height)



$page:=New object("objects";New object("myListBox";$obj)) $form:=New 
object(“pages";New collection(Null;$page))

$form:=New object("windowTitle";"Select a 
Map:";"windowMinWidth";500;"windowMinHeight";300;"pages";New 
collection(Null;$page))  

Now, this dynamic form only shows a listbox, and I want to add a button to the 
form. I assume this button object has to be added to the ‘Objects’ object in 
$page.

But, how do I do that? I tried object arrays and collections, but neither of 
them produces the correct result. 


Secondly, the listbox displays an entity selection. How do I get the row number 
that has been selected?



Regards,

Rudy Mortier
Two Way Communications bvba 



**
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: Creating a form object to use as dynamic form

2018-09-24 Thread John DeSoi via 4D_Tech
On Sep 24, 2018, at 9:44 AM, Two Way Communications via 4D_Tech 
<4d_tech@lists.4d.com> wrote:
> 
> $page:=New object("objects";New object("myListBox";$obj)) $form:=New 
> object(“pages";New collection(Null;$page))
> 
> $form:=New object("windowTitle";"Select a 
> Map:";"windowMinWidth";500;"windowMinHeight";300;"pages";New 
> collection(Null;$page))
> 
> Now, this dynamic form only shows a listbox, and I want to add a button to 
> the form. I assume this button object has to be added to the ‘Objects’ object 
> in $page.

Yes, each object on the page is represented by the unique name you give it, 
then the the page is part of a collection of pages for the form. Something like

$oPage:=New object
$oPage.myButton:=$oButton1
$oPage.myListbox:=$oListbox

$oForm.pages:=New collection
$oForm.pages[1]:=New object
$oForm.pages[1].objects:=$oPage

Your code will be more readable and maintainable if you write methods to 
generate each object type.


> Secondly, the listbox displays an entity selection. How do I get the row 
> number that has been selected?

You specify the currentItemSource property for the dynamic listbox. I use Form 
and specify a property based on the object name like this:


$form:=Command name(1466)+"."  //Form command

$0:=New object
$0.type:="listbox"
$0.listboxType:="collection"

$0.currentItemSource:=$form+$name+"__currentItem"
$0.currentItemPositionSource:=$form+$name+"__currentItemPosition"
$0.selectedItemsSource:=$form+$name+"__selectedItems"


John DeSoi, Ph.D.

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

[ANN] 4DMethod September 26th Meeting - Subforms as dynamic data objects - Rethinking the 4D form, Kirk Brooks

2018-09-24 Thread Ed Hammond via 4D_Tech
Hope to see you at our next 4DMethod  meeting on 
Wednesday, September 26th, 12:00 noon, CDT (UTC?5:00)!  Kirk Brooks of The 
Energy House will introduce you to the new way of thinking about the whole 
structure of a 4D database as compared to simply figuring out how to make it do 
what 4D has always done before.  This 4D v17 demo encapsulates new approaches 
to interface development with a focus on object based definition of dynamic 
forms and subforms made available via component.


Kirk will share a development tool for building and installing toolbars on the 
fly in an app.  The process uses dynamic forms and an editor that gives you a 
way to build and manage these forms.


The second part is looking at the way it works. This leans heavily on the new 
ORDA features for managing forms, data in the forms, passing it back and forth 
between listboxes, subforms and disk files.




Edgar Hammond ehamm...@questinformation.com

Quest Information Systems


The Art Institute of Chicagoeham...@artic.edu


**
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: Creating a form object to use as dynamic form

2018-09-24 Thread Kirk Brooks via 4D_Tech
Jody,
You are correct about the form editor. I've been dabbling with building
even a simplified form editor and it's not a trivial task.

On the other hand my work with dynamic forms has shown me the mechanics of
the current form editor and the approach employed by the dynamic forms part
is very different. I suspect it's going to be a tough circle to square.

But frankly I never thought Laruant would be able to make something like
ORDA either so I suspect there's something in the works.

On Mon, Sep 24, 2018 at 7:57 AM Jody Bevan via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> ... but my hope is that this is just a necessary 1st step to being able
> to create a form using the normal 4D Form Editor, Form Method, Object
> Methods and then be able to save them as ‘text’ that can then be sent to
> clients.
>

-- 
Kirk Brooks
San Francisco, CA
===

*We go vote - they go home*
**
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: How to get the current time in a specified time zone

2018-09-24 Thread Timothy Penner via 4D_Tech
> There is also the NET_TIME command in 4D Internet Commands:
> http://doc.4d.com/4Dv17/4D/17/NET-Time.301-3785509.en.html

Something like this:

C_TIME($vTime)
C_DATE($vNetDate)
C_LONGINT($vNetTime;$vOffset;$err)
$vOffset:=-7
$err:=NET_Time ("time.nist.gov";$vNetDate;$vNetTime;$vOffset)
If ($err=0)
$vTime:=Time(Time string($vNetTime))  //Convert the LongInt time to a 4D Time
 End if

-Tim



**
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: Creating a form object to use as dynamic form

2018-09-24 Thread Jody Bevan via 4D_Tech
Rudy:

I agree with you. You think Belgium has few courses - try Belize!

I am with you trying to master it is a challenge. So much new in v17. 
Fortunately we can still code as we did, and learn in snippets as we have time. 
I do hope they have a course happening around the USA on this new stuff because 
I will certainly want to get up there to take it. I doubt they will do Belize - 
LOL.

Jody Bevan
Argus Productions Inc.


> On Sep 24, 2018, at 3:03 PM, Two Way Communications via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> Thanks Jody.
> 
> 4D's progress is actually quite stunning this last few years.
> 
> The downside is that, at least here in Belgium, it is hard to get the 
> required training in order to master all of that. So, I get stuck quite a lot 
> lately with ORDA, 4D Write pRo, 4D for iOS and all the other new stuff.
> Reading the docs and looking at the examples only get you so far…
> 
> But I’m sure we will get there in the end.
> 
> Regards,
> 
> Rudy Mortier
> Two Way Communications bvba 
> 

**
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: How to get the current time in a specified time zone

2018-09-24 Thread Keisuke Miyako via 4D_Tech
actually you can get UTC time without a network connection:

// v17
C_TIME($t)
XML DECODE(Delete string(Timestamp;24;1);$t)

// before
C_TIME($t)
XML DECODE(Delete string(string(Current date;ISO date GMT;Current 
time);20;1);$t)

both of which are effectively "substring" + "time" operations that strip away 
the date.

however, time in a specified zone requires date information,
because of day light savings and other peculiarities.

c.f.

https://github.com/miyako/4d-plugin-time-and-number
https://github.com/miyako/4d-plugin-tz



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

How to get the current time in a specified time zone

2018-09-24 Thread Pat Bensky via 4D_Tech
Using v16:
I've figured out how to get the current GMT time using cURL. (Code at the
bottom if anybody is interested).
Now I need to get the current time in a different time zone - eg in France.
Any ideas how to do that?



==

  // GetTimeGMT

  // Gest the current time in GMT from Google

  // 21/09/18 pb

*C_LONGINT*(*$0*)

$input:="curl -I https://www.google.com/;  // this gets GMT from Google

$empty:=""

*LAUNCH EXTERNAL PROCESS*($input;$empty;$output;$error)

*$0*:=0

*If* ($output#"")

$pos:=*Position*("GMT";$output)

*If* ($pos>0)

$time:=*Substring*($output;$pos-9;8)

$pos:=*Position*(":";$time)

*If* ($pos>0)

*$0*:=*Num*(*Substring*($time;1;$pos-1))

*End if*

*End if*

*End if*

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

RE: How to get the current time in a specified time zone

2018-09-24 Thread Timothy Penner via 4D_Tech
Interesting approach; I also just found these:

UTC: http://worldclockapi.com/api/json/utc/now
PST: http://worldclockapi.com/api/json/pst/now
EST: http://worldclockapi.com/api/json/est/now

The output is JSON, so it should be easily parsed.

There is also the NET_TIME command in 4D Internet Commands:
http://doc.4d.com/4Dv17/4D/17/NET-Time.301-3785509.en.html



**
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: Creating a form object to use as dynamic form

2018-09-24 Thread Two Way Communications via 4D_Tech
Thanks Jody.

4D's progress is actually quite stunning this last few years.

The downside is that, at least here in Belgium, it is hard to get the required 
training in order to master all of that. So, I get stuck quite a lot lately 
with ORDA, 4D Write pRo, 4D for iOS and all the other new stuff.
Reading the docs and looking at the examples only get you so far…

But I’m sure we will get there in the end.

Regards,

Rudy Mortier
Two Way Communications bvba 



> On 24 Sep 2018, at 16:57, Jody Bevan via 4D_Tech <4d_tech@lists.4d.com> wrote:
> 
> Sorry Rudy, not an answer to your question, but topical I think.
> 
> Being able to create a sophisticated form via code is a fantastic feature. It 
> is like the coding I did back in 1982/1983. Back when I first got my hands on 
> my own copy of 4D version 2.0.10  the Graphical form editor was such a 
> liberating way of creating forms, compared to the way I needed to do it in 
> Pascal.
> 
> This really is a great feature, but my hope is that this is just a necessary 
> 1st step to being able to create a form using the normal 4D Form Editor, Form 
> Method, Object Methods and then be able to save them as ‘text’ that can then 
> be sent to clients.
> 
> We have often had the need to send multiple forms to different clients for 
> them to run.  Then the client needs / forced to (by regulations) have a new 
> version of the form. That is great, but they still have lots of data that 
> they collect via the old form and need to be able to display that data in the 
> form they used at the time. 
> 
> In the last major application we did, we have ~ 10,000 forms with each client 
> having about 150 of them. Each client though would have a different set of 
> forms. When 4D announced this feature I hoped that it will lead to fulfilling 
> this need. Then as 4D developers we can provide a rich, consistent interface 
> within the product rather than having to resort to forms in WebAreas, PDFs, 
> etc. This will help us 4D developers stick within our expertise of 4D and be 
> more productive.
> 
> Jody Bevan
> Argus Development Inc.
> 
> 
>> On Sep 24, 2018, at 8:44 AM, Two Way Communications via 4D_Tech 
>> <4d_tech@lists.4d.com> wrote:
>> 
>> I can’t figure out how to do this … 
>> 
>> Using a dynamic form, I am trying to build a generic list of records to 
>> display to the user and to allow him to select 1 record.
>> 
>> I used the example from the tech note on how to create a dynamic form that 
>> shows a listbox.
>> 
>> To build this $form object variable, the commands New object and others are 
>> used.
>> 
>> This listbox object is added to the $page object in the $form object, which 
>> will be used in the DIALOG command.
>> 
>> 
>> $obj:=New object("type";"listbox";"listboxType";"collection";\ 
>> "dataSource";$colName;"left";0;"top";0;"width";$width+15;"height";$height)
>> 
>> 
>> 
>> $page:=New object("objects";New object("myListBox";$obj)) $form:=New 
>> object(“pages";New collection(Null;$page))
>> 
>> $form:=New object("windowTitle";"Select a 
>> Map:";"windowMinWidth";500;"windowMinHeight";300;"pages";New 
>> collection(Null;$page))   
>> 
>> Now, this dynamic form only shows a listbox, and I want to add a button to 
>> the form. I assume this button object has to be added to the ‘Objects’ 
>> object in $page.
>> 
>> But, how do I do that? I tried object arrays and collections, but neither of 
>> them produces the correct result. 
>> 
>> 
>> Secondly, the listbox displays an entity selection. How do I get the row 
>> number that has been selected?
>> 
>> 
>> 
>> Regards,
>> 
>> Rudy Mortier
>> Two Way Communications bvba 
>> 
> 
> **
> 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
> **

**
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: Creating a form object to use as dynamic form

2018-09-24 Thread Tim Nevels via 4D_Tech
On Sep 24, 2018, at 2:00 PM, Rudy Mortier wrote:

> I can’t figure out how to do this … 
> 
> Using a dynamic form, I am trying to build a generic list of records to 
> display to the user and to allow him to select 1 record.
> 
> I used the example from the tech note on how to create a dynamic form that 
> shows a listbox.
> 
> To build this $form object variable, the commands New object and others are 
> used.
> 
> This listbox object is added to the $page object in the $form object, which 
> will be used in the DIALOG command.
> 
> $obj:=New object("type";"listbox";"listboxType";"collection";\ 
> "dataSource";$colName;"left";0;"top";0;"width";$width+15;"height";$height)
> 
> $page:=New object("objects";New object("myListBox";$obj)) $form:=New 
> object(“pages";New collection(Null;$page))
> 
> $form:=New object("windowTitle";"Select a 
> Map:";"windowMinWidth";500;"windowMinHeight";300;"pages";New 
> collection(Null;$page))
> 
> Now, this dynamic form only shows a listbox, and I want to add a button to 
> the form. I assume this button object has to be added to the ‘Objects’ object 
> in $page.
> 
> But, how do I do that? I tried object arrays and collections, but neither of 
> them produces the correct result. 

The new Dynamic Forms feature in v17 is new and documentation is very limited, 
as you already know. Example code is even more limited.  It takes a lot of 
trial and error to get it to work. I’ve spent hours getting things to work for 
my little project. And some things I’ve still not been able to figure out. 
Example: how to set the color of a line or a rectangle. 

What is desperately needed is the ability to dump a 4D form created in the Form 
Editor to JSON. Then you would be able to convert an existing form to a dynamic 
form and you would have example code to understand what is needed to make that 
button or configure that listbox to work the way you want.  Hoping that 
command/feature will be released in a v17 R.

I’ve done some work with Dynamic Forms and here are some tips/info on building 
them:

You have to create a starter object for the form. Once that form object is 
created, you can then add more object to it for each item on the form. Here is 
sample code that will create that starter object

$formObject_o:=New object(\
   "markerHeader";0;\
   "markerBody";72;\
   "method";"label_SetObjectFontSize";\
   "pages";New collection(\
   Null;\
   New object(\
   "objects";New object)))

You don’t really  need “markerHeader” or “markerBody” for a display form, but I 
need them because I’m building forms that are used for printing. 

Next you need to add objects to “pages” collection. Page zero is “Null” in my 
example, I’ll add objects to Page 1.

Here is code to add a rectangle to Page 1:

$object_o:=New object(\
   "type";"rectangle";\
   "fill";"transparent";\
   "strokeWidth";1;\
   "left";10;\
   "top";10;\
   "width";100;\
   "height";100)

$objectName_t:=“myRectangle”
OB SET($formObject_o.pages[1].objects;$objectName_t;$object_o)

Here is code for an object that is a “input” variable. In this case it is not 
enterable as I’m using it for printing.

myVariable_t:=“some value to display”

$object_o:=New object(\
   "type";"input";\
   "dataSource”;”myVariable_t";\
   "dataSourceTypeHint";"text";\
   "enterable";False;\
   "borderStyle";"none";\
   "fill";"transparent";\
   "textAlign";"left";\
   "left”;20;\
   "top”;20;\
   "width";200;\
   "height";11;\
   "fontFamily";"Arial";\
   "fontSize";9;\
   "fontWeight";"Bold”)

$objectName_t:=“myVariable”
OB SET($formObject_o.pages[1].objects;$objectName_t;$object_o)

Finally, here is code to add a button to a form:

$object_o:=New object(\
   "type”;"button";\
   “text”;"OK";\
   “action”;”Cancel";\
   "left";100;\
   "top";100;\
   "width”;70;\
   "height”;20)

$objectName_t:=“myButton”
OB SET($formObject_o.pages[1].objects;$objectName_t;$object_o)

As you can see dot notation comes in very handy when working with Dynamic 
Forms. Each object you add to a page needs a unique name. You decide what  that 
name is.

Also property names are case sensitive, and even some property values are case 
sensitive. Using the wrong case will not cause an error, but the object will 
just not work. So read the docs and if it says that a “type” value is “button” 
then don’t try “Button” because it may not work. 

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