Re: 4D JSON Date Bug

2019-02-25 Thread Bart Davis via 4D_Tech
Thanks Jeremy,

I turned on the compatibility setting for "Use date type instead of ISO date 
format in objects" and restarted 4D, but still get the same results from the 
code below.  Even if the setting did result in the correct answer, I think that 
4D made a bad decision to make the default behavior change the date for a date 
string that doesn't include time (ie. no T00:00:00).

Bart

> On Feb 24, 2019, at 8:39 PM, Jeremy French  wrote:
> 
> Hi Bart,
> 
> If you store a date in an Object as a string, 4D interprets that date as a 
> UTF date.
> 
> So “2019-02-24” (giving only the date but not time) is interpreted as 
> midnight on the 24th. That is at the stroke of midnight when the 24th day 
> **starts**.
> 
> When you retrieve the value around 6:30 PST on the 24th, 4D is converting to 
> your local time — which is several hours **before** the 24th begins. Hence 
> you see the 23rd.
> 
> If you pass a 4D date, the problem won’t happen. That is replace the string 
> ("2019-02-24”) with a 4D date (#2019-02-24#).
> 
> There’s also a compatibility setting that where you can specify that string 
> dates are to be treated as 4D dates. That is, no time associated with the 
> date. Then your expression:
> 
>> OB SET($obj;"apiDate";"2019-02-24")
> 
> would always return the 24th
> 
> Best regards,
> Jeremy
> 
> 
>> On Feb 24, 2019, at 9:24 PM, Bart Davis via 4D_Tech <4d_tech@lists.4d.com> 
>> wrote:
>> 
>> If you store a 4D date value in an object and retrieve it the value is 
>> correct.  However, if you retrieve a date that is stored in the format 
>> -MM-DD, the date returned is one day less that the date stored.
>> 
>> The code below illustrates the issue.  I have only tested this on Mac OS 
>> using 4D v17.1  (Note:  I tested this at 6:30 pm PST and am not sure if GMT 
>> offset has any effect)
>> 
>> Has anyone else experienced this issue?
>> 
>> Thanks,
>> Bart
>> 
>> C_DATE($4dDate;$apiDate)
>> C_OBJECT($obj)
>> 
>> $obj:=New object
>> $today:=Current date
>> 
>> OB SET($obj;"4Ddate";$today)
>> OB SET($obj;"apiDate";"2019-02-24")
>> 
>> $4dDate:=ob get($obj;"4Ddate";Is date)  // date returned is correct 
>> 2019-02-24
>> $apiDate:=ob get($obj;"apiDate";Is date) // ERROR: date returned is 
>> 2019-02-23
> 

**
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 JSON Date Bug

2019-02-24 Thread Bart Davis via 4D_Tech
I just discovered what I think is a serious bug with 4D reading dates from an 
object.  

If you store a 4D date value in an object and retrieve it the value is correct. 
 However, if you retrieve a date that is stored in the format -MM-DD, the 
date returned is one day less that the date stored.

The code below illustrates the issue.  I have only tested this on Mac OS using 
4D v17.1  (Note:  I tested this at 6:30 pm PST and am not sure if GMT offset 
has any effect)

Has anyone else experienced this issue?

Thanks,
Bart

C_DATE($4dDate;$apiDate)
C_OBJECT($obj)

$obj:=New object
$today:=Current date

OB SET($obj;"4Ddate";$today)
OB SET($obj;"apiDate";"2019-02-24")

$4dDate:=ob get($obj;"4Ddate";Is date)  // date returned is correct 2019-02-24
$apiDate:=ob get($obj;"apiDate";Is date) // ERROR: date returned is 2019-02-23



**
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: Do I want to use SELECTION TO ARRAY instead of GOTO SELECTED RECORD server-side in V17

2018-09-17 Thread Bart Davis via 4D_Tech
> Bernd,
> 
> Thanks for the report, it's interesting and believable. In this case, I
> have to get the data into memory to send it... I guess I could write to a
> file, load that and then send it. Interesting concept, thanks!

No need to write to a file.  Appending text to a text variable is very slow, 
but using TEXT TO BLOB($textToAdd;$blob;UTF8 text without length;*)  is very 
fast.  Give that a try and see the huge speed difference.

Bart
**
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: zipping files

2017-07-28 Thread Bart Davis via 4D_Tech
This method works great on Mac without using any plugin.  I'm not sure if it 
can be tweaked to work on Windows. 



  //zipFolderItem(sourcePath{;archivePath)->archivePath
  // -- zip file or folder. If success returns archivePath

C_TEXT($0;$1;$2;$cmd;$sourcePath;$archivePath)
C_LONGINT($ctr)
C_BOOLEAN($addToExisting)

$sourcePath:=$1
If (Count parameters=1)
$archivePath:=$sourcePath+".zip"
Else 
$archivePath:=$2
If ($archivePath#"@.zip")
$archivePath:=$archivePath+".zip"
End if 
$addToExisting:=True
End if 

If (Not($addToExisting))
  // get unique archive path
While ((Test path name($archivePath)=Is a document) | (Test path 
name($archivePath)=Is a folder))
$ctr:=$ctr+1
$archivePath:=$sourcePath+" "+String($ctr)+".zip"
End while 
End if 

$sourcePath:=Convert path system to POSIX($sourcePath)
$archivePath:=Convert path system to POSIX($archivePath)
$cmd:="ditto -c -k '"+$sourcePath+"' '"+$archivePath+"'"

LAUNCH EXTERNAL PROCESS($cmd)

$archivePath:=Convert path POSIX to system($archivePath)

If (Test path name($archivePath)=Is a document)
$0:=$archivePath
End if 

> On Jul 28, 2017, at 9:15 AM, 4d_tech-requ...@lists.4d.com wrote:
> 
> Message: 1
> Date: Thu, 27 Jul 2017 15:24:26 -0600
> From: Jody Bevan 
> To: 4D iNug Technical <4d_tech@lists.4d.com>
> Subject: zipping files
> Message-ID: <79da757f-505f-4dbf-be79-2604f8d53...@gmail.com>
> Content-Type: text/plain; charset=utf-8
> 
> I have looked through the Knowledgebase, and past nug posts. I tried PHP to 
> do this but got no where (something obviously I am doing).
> I ended up (thus far) with miyako’s 4D plugin for zipping.
> 
> I go into his test db and try it out and it works perfectly. So now I want to 
> implement in our shell.
> 
> I place the plugin in the Plugin folder of our application and restart.
> 
> That is fine, and I now have a plugin that loads at startup and when I write 
> code the plugin command shows up as a plugin and the constants as well.
> 
> I run the code and it always fails!
> 
> So any ideas as to what I am doing wrong? Is this actually a component and 
> not ‘just’ a plug-in and I have to do more?
> 
> Any help appreciated, as I continue to struggle with this.
> 
> Thanks
> 
> Jody Bevan
> ARGUS Productions Inc.
> Developer
> Argus Productions Inc. 

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

4D SQL Implementation

2017-04-14 Thread Bart Davis via 4D_Tech

> On Apr 14, 2017, at 2:35 AM, 4d_tech-requ...@lists.4d.com wrote:
> 
> 
> Message: 3
> Date: Thu, 13 Apr 2017 16:31:15 -0400
> From: Jeffrey Kain 
> To: 4D iNug Technical <4d_tech@lists.4d.com>
> Subject: Re: How to create Object field via SQL
> Message-ID: 
> Content-Type: text/plain; charset=us-ascii
> 
> It's almost as if the SQL engine is a bolted-on afterthought to 4D that 
> doesn't receive much love at all from the development team.

I couldn't agree more with this statement "It's almost as if the SQL engine is 
a bolted-on afterthought to 4D that doesn't receive much love at all from the 
development team."

- The fact that you can't use SQL in a trigger when a record is inserted, 
updated or deleted via SQL is baffling.  Every other SQL database seems to be 
able to do it.

-  You still can't use local variables in a EXECUTE IMMEDIATE SQL statement in 
a compiled application?  Is it really that difficult to implement?

- Could there be some internal semaphore/blocking code that prevents some part 
of a SQL query in one process from executing (this includes ORDER BY) when a 
SQL query in executing in a different process?  In two different web 
applications that have heavy concurrent use, progress bar windows start 
appearing on the screen saying ORDER BY or LOADING DATA and as more processes 
are initiated more windows appear the application grinds to a stop and must be 
killed and restarted.  These are simple queries with Order By on indexed fields 
on small data sets.  I replaced the SQL queries with the standard 4D Query 
language and there are no more performance issues.  On all heavily used queries 
I have replaced SQL with 4D query language.

- Why isn't the use of 4D array variables in SQL queries supported?

Assuming $aRecordID is a populated Longint Array...

Begin SQL
  Select * from Table where ID in :$aRecordID
End SQL

Bart

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