Re: Receive packet stop character

2020-03-26 Thread Randy Kaempen via 4D_Tech
John,

This doesn’t answer your question, but there are other special cases as well.  
Even if you’re using a carriage return as the end-of-line, you could have it 
inside some of your data, if the text has quotes around it.  Many CSV files are 
like this.  In that case, you need to process character at a time to see if 
you’re inside of quotes or not.  If you are, then the carriage return is just 
more of the data for the field.  If you are not inside quotes, then it acts as 
the record delimiter.  That can cause lines to truncate early if you’re just 
doing:

RECEIVE PACKET($DocRef;$TextValue;Char(13))

Sorry to be a downer, but I’ve run into all sorts of exceptions doing imports.


Randy Kaempen
Intellex Corporation



**
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: Receive packet stop character

2020-03-25 Thread Keisuke Miyako via 4D_Tech
sometimes, it might just be easier to read the entire text with

Document to text (which can normalise the EOL character)

and process the text afterwards with Match regex or Position.

2020/03/26 13:51、Chip Scheide via 4D_Tech 
<4d_tech@lists.4d.com>のメール:
it is too late here to dig up the code...

**
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: Receive packet stop character

2020-03-25 Thread JOHN BAUGHMAN via 4D_Tech
Thanks to all who responded. I am really confused now. Turns out the problem 
was in fact what I suspected all along… the end of row delimiter was a line 
feed and not a carriage return. 

This begs a few questions …

Why did this change all of a sudden. I had been working with the same 
text document for most of the day and it was working fine. This is an old 
project and I have never had an issue with this particular section of cade 
before.

On a Mac doesn’t TextEdit use carriage returns? It has always done so 
for me in the past. If I hit the return key on my keyboard it should be a 
carriage return. As soon as I saw this problem earlier today, I re-typed all 
the paragraph endings with a return using the return key on my keyboard in 
TextEdit. In the past if there was a line feed in the document it always showed 
up as a blank character. In other words, back space the carriage return and you 
had to backspace one more time to get to the end of the paragraph.

No need to respond. I knew what the problem most likely was before I 
sent my first message. Thanks to Spencer Hinsdale for suggesting to use USE 
CHARACTER SET("iso-8859-1";1). It revealed the \n in the returned package. 
Otherwise I would have continued to chase my tail on this one.

John




>> On Mar 25, 2020, at 8:10 PM, Spencer Hinsdale via 4D_Tech 
>> <4d_tech@lists.4d.com> wrote:
>> 
>> 
>> Does the behavior change if you insert
>> USE CHARACTER SET("iso-8859-1";1)
>> before receive packet
>> 
>> 
>> On 3/25/20, 8:01 PM, "4D_Tech on behalf of JOHN BAUGHMAN via 4D_Tech" 
>> <4d_tech-boun...@lists.4d.com on behalf of 4d_tech@lists.4d.com> wrote:
>> 
>>> On Mar 25, 2020, at 3:54 PM, Jeffrey Kain via 4D_Tech 
>>> <4d_tech@lists.4d.com> wrote:
>>> 
>>> You've got a smart quote in there... email post typo or is it in your code?
>> 
>>  Actually I typed that in while drafting the email. This is old code 
>> that has worked for years. I also tried changing the code to char(carriage 
>> return)
>> 
>> 
>> 
>> **
>> 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
>> **
> 
> _
> Bob McKeever  http://www.mswl.com 
> McKeever's Software Wizardry
> Port Coquitlam, B.C.
> bobmckee...@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
> **

**
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: Receive packet stop character

2020-03-25 Thread Chip Scheide via 4D_Tech
John,
you probably should not be reading individual lines of data from the disk.  
This takes mach more time...

it is too late here to dig up the code... but here is an outline of a better 
(best?) way to deal with text files:

Read_File_to_Text_Array
`$1 - pointer - to text array
`$2 - time - document reference

Repeat 
insert element into array
receive packet($DocRef; $Array_ptr->{$counter}; 300megs)
if (last character is not EOL)
receive until EOL
until end of file

NOTES:
- you can check for what EOL character is by examining the first text array 
element looking for whatever EOL marker you expect
- this in most cases reads the entire text file into a single text array element
- 300 megs was an empirically determined number (v13) where 4D was OK with 
reading and managing too much larger and 4D got/gets unhappy
- the test for EOL in the repeat loop is to allow each text array element to 
end on the end of 1 line of data - to avoid breaking a line across 2 text 
elements
- this works for any size file
- it makes processing the imported data much faster - as everything is in 
memory rather then reading from disk each line.
- if you do not have one written already, a text parser which keeps a numeric 
counter as to where it left off is very fast an efficient for moving through 
text data

if you need code for either the file reading or text parsing let me know I will 
get it you.

Chip




> I have a tab delimited text file and I want to get the first row with…
> 
> C_TEXT($TextValue)
> $DocRef:=Open document($IndexPath)
> RECEIVE PACKET($DocRef;$TextValue;”\r")
> CLOSE DOCUMENT($DocRef)
> 
> This was working fine until about an hour ago when it suddenly 
> started bringing in the whole document which has many rows. Using “\t
> ” works fine just bringing the first field in the first row.
> Any ideas?
> 
> Mac OS High Sierra
> 4D v14 in Unicode mode
> 
> John
> 
> 
> John Baughman
> Kailua, Hawaii
> (808) 262-0328
> john...@hawaii.rr.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
> **

Hell is other people 
 Jean-Paul Sartre
**
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: Receive packet stop character

2020-03-25 Thread Chip Scheide via 4D_Tech
John,
try:

RECEIVE PACKET($DocRef;$TextValue;Char(13)) //return
or
RECEIVE PACKET($DocRef;$TextValue;Char(10)) // line feed
or
RECEIVE PACKET($DocRef;$TextValue;Char(13)+Char(10)) // both of the above

depending on how much control you have on the incoming file it could be any 
combination
my preferred way is:
$EOL := Test_EOL($DocRef)
if ($EOL #"")
RECEIVE PACKET($DocRef;$TextValue;$EOL)
`do stuff

below written in email so...

Test_EOL
`$1 - time - document reference
`RETURNS - text - EOL character or empty string if none found

c_time($1;$DocRef)
c_text($TextValue;Return;$0)
c_boolean($EOF)

$DocRef := $1

Repeat
RECEIVE PACKET($DocRef;$TextValue;100) 
case of
: (position(char(13)+char(10),$TextValue) >0)
$return := char(13)+char(10)
: (position(char(13),$TextValue) >0)
$return := char(13)
: (position(char(10),$TextValue) >0)
$return := char(10)
:(OK = 0)
$EOF:=true
end case
until ($return#"") | ($EOF)
`I forget the command - but reset read point in file to start
`end


> I have a tab delimited text file and I want to get the first row with…
> 
> C_TEXT($TextValue)
> $DocRef:=Open document($IndexPath)
> RECEIVE PACKET($DocRef;$TextValue;”\r")
> CLOSE DOCUMENT($DocRef)
> 
> This was working fine until about an hour ago when it suddenly 
> started bringing in the whole document which has many rows. Using “\t
> ” works fine just bringing the first field in the first row.
> Any ideas?
> 
> Mac OS High Sierra
> 4D v14 in Unicode mode
> 
> John
> 
> 
> John Baughman
> Kailua, Hawaii
> (808) 262-0328
> john...@hawaii.rr.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
> **

Hell is other people 
 Jean-Paul Sartre
**
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: Receive packet stop character

2020-03-25 Thread Robert McKeever via 4D_Tech
So, open the file with a hex editor, and see what ends the first line. I use 
Hex Fiend for that on the Mac.

> On Mar 25, 2020, at 8:10 PM, Spencer Hinsdale via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> 
> Does the behavior change if you insert
> USE CHARACTER SET("iso-8859-1";1)
> before receive packet
> 
> 
> On 3/25/20, 8:01 PM, "4D_Tech on behalf of JOHN BAUGHMAN via 4D_Tech" 
> <4d_tech-boun...@lists.4d.com on behalf of 4d_tech@lists.4d.com> wrote:
> 
>> On Mar 25, 2020, at 3:54 PM, Jeffrey Kain via 4D_Tech <4d_tech@lists.4d.com> 
>> wrote:
>> 
>> You've got a smart quote in there... email post typo or is it in your code?
> 
>   Actually I typed that in while drafting the email. This is old code 
> that has worked for years. I also tried changing the code to char(carriage 
> return)
> 
> 
> 
> **
> 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
> **

_
Bob McKeever  http://www.mswl.com 
McKeever's Software Wizardry
Port Coquitlam, B.C.
bobmckee...@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
**

Re: Receive packet stop character

2020-03-25 Thread Spencer Hinsdale via 4D_Tech

Does the behavior change if you insert
USE CHARACTER SET("iso-8859-1";1)
before receive packet


On 3/25/20, 8:01 PM, "4D_Tech on behalf of JOHN BAUGHMAN via 4D_Tech" 
<4d_tech-boun...@lists.4d.com on behalf of 4d_tech@lists.4d.com> wrote:

> On Mar 25, 2020, at 3:54 PM, Jeffrey Kain via 4D_Tech 
<4d_tech@lists.4d.com> wrote:
> 
> You've got a smart quote in there... email post typo or is it in your 
code?

Actually I typed that in while drafting the email. This is old code 
that has worked for years. I also tried changing the code to char(carriage 
return)



**
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: Receive packet stop character

2020-03-25 Thread JOHN BAUGHMAN via 4D_Tech
> On Mar 25, 2020, at 3:54 PM, Jeffrey Kain via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> You've got a smart quote in there... email post typo or is it in your code?

Actually I typed that in while drafting the email. This is old code 
that has worked for years. I also tried changing the code to char(carriage 
return)

> Could the line ending have change to something else like \n ?

No. See my response to Chuck.

John


> 
>> On Mar 25, 2020, at 9:31 PM, JOHN BAUGHMAN via 4D_Tech 
>> <4d_tech@lists.4d.com> wrote:
>> 
>> I have a tab delimited text file and I want to get the first row with…
>> 
>> C_TEXT($TextValue)
>> $DocRef:=Open document($IndexPath)
>> RECEIVE PACKET($DocRef;$TextValue;”\r")
>> CLOSE DOCUMENT($DocRef)
>> 
>> This was working fine until about an hour ago when it suddenly started 
>> bringing in the whole document which has many rows. Using “\t” works fine 
>> just bringing the first field in the first row.
>> Any ideas?
>> 
>> Mac OS High Sierra
>> 4D v14 in Unicode mode
> 
> **
> 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: Receive packet stop character

2020-03-25 Thread JOHN BAUGHMAN via 4D_Tech

> On Mar 25, 2020, at 4:46 PM, Charles Miller via 4D_Tech 
> <4d_tech@lists.4d.com> wrote:
> 
> Perhaps it is a new line

Trying to figure out what was wrong I went into the text file with TextEdit and 
deleted each return making sure that there was no other hidden characters in 
there and reinserted the return with the return key. I also opened it up in 
Pages and showing invisibles all were carriage returns I also brought in other 
text files that have worked fine up to now and it did not work with them either.


> 
> On Wed, Mar 25, 2020 at 9:31 PM JOHN BAUGHMAN via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> 
>> I have a tab delimited text file and I want to get the first row with…
>> 
>> C_TEXT($TextValue)
>> $DocRef:=Open document($IndexPath)
>> RECEIVE PACKET($DocRef;$TextValue;”\r")
>> CLOSE DOCUMENT($DocRef)
>> 
>> This was working fine until about an hour ago when it suddenly started
>> bringing in the whole document which has many rows. Using “\t” works fine
>> just bringing the first field in the first row.
>> Any ideas?
>> 
>> Mac OS High Sierra
>> 4D v14 in Unicode mode
>> 
>> John
>> 
>> 
>> John Baughman
>> Kailua, Hawaii
>> (808) 262-0328
>> john...@hawaii.rr.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
>> **
> 
> -- 
> -
> Chuck Miller Voice: (617) 739-0306 Fax: (617) 232-1064
> Informed Solutions, Inc.
> Brookline, MA 02446 USA Registered 4D Developer
>   Providers of 4D, Sybase & SQL Server connectivity
>  https://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.
> **
> 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: Receive packet stop character

2020-03-25 Thread Charles Miller via 4D_Tech
Perhaps it is a new line

On Wed, Mar 25, 2020 at 9:31 PM JOHN BAUGHMAN via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> I have a tab delimited text file and I want to get the first row with…
>
> C_TEXT($TextValue)
> $DocRef:=Open document($IndexPath)
> RECEIVE PACKET($DocRef;$TextValue;”\r")
> CLOSE DOCUMENT($DocRef)
>
> This was working fine until about an hour ago when it suddenly started
> bringing in the whole document which has many rows. Using “\t” works fine
> just bringing the first field in the first row.
> Any ideas?
>
> Mac OS High Sierra
> 4D v14 in Unicode mode
>
> John
>
>
> John Baughman
> Kailua, Hawaii
> (808) 262-0328
> john...@hawaii.rr.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
> **

-- 
-
 Chuck Miller Voice: (617) 739-0306 Fax: (617) 232-1064
 Informed Solutions, Inc.
 Brookline, MA 02446 USA Registered 4D Developer
   Providers of 4D, Sybase & SQL Server connectivity
  https://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.
**
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: Receive packet stop character

2020-03-25 Thread Jeffrey Kain via 4D_Tech
You've got a smart quote in there... email post typo or is it in your code?

Could the line ending have change to something else like \n ?

> On Mar 25, 2020, at 9:31 PM, JOHN BAUGHMAN via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> I have a tab delimited text file and I want to get the first row with…
> 
> C_TEXT($TextValue)
> $DocRef:=Open document($IndexPath)
> RECEIVE PACKET($DocRef;$TextValue;”\r")
> CLOSE DOCUMENT($DocRef)
> 
> This was working fine until about an hour ago when it suddenly started 
> bringing in the whole document which has many rows. Using “\t” works fine 
> just bringing the first field in the first row.
> Any ideas?
> 
> Mac OS High Sierra
> 4D v14 in Unicode mode

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