Turn Text lines with "Return" to Records

14 messages Options
Embed this post
Permalink
Salman Maidan-3

Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
Hi Experts

FMPA 10
WinXp

I know this has come up before but I could not find it on the archives, I
have a global text field full of text lines with carriage return at the end
of each line. I would like to turn each line into a record.
Can someone help with the script. Much appreciated.

Regards
Salman
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Lorne & Joan Walton

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
A looping script with something like:

Set Variable ( $n ; 1 )
Loop
   New Record
   Set Field ( Yourfield ; GetValue ( globalField ) ; $n ) )
   Set Variable ( $n ; $n+1 )
   Exit Loop If ( you've used up your "globalField" )
End Loop

...would seem the quick and dirty method. Is there a better way?

On Jul 2, 2009, at 9:43 AM, Salman Maidan wrote:

> I know this has come up before but I could not find it on the  
> archives, I
> have a global text field full of text lines with carriage return at  
> the end
> of each line. I would like to turn each line into a record.
> Can someone help with the script. Much appreciated.

--
Don't sweat the petty stuff. And don't pet the sweaty stuff.
 Lorne Walton, Maple Ridge, BC, Canada 

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Beverly Voth-2

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
In reply to this post by Salman Maidan-3
Salman, try the Export Field Contents. Then reimport the text file into a
table. You should get the 'returns' as one record. You  can also get TABs in
that export and it you don't have the same number of "tabs" per "line", then
you may get a strange (or not even work) import.

Beverly


On 7/2/09 12:43 PM, "Salman Maidan" <[hidden email]> wrote in whole or
in part:

> Hi Experts
>
> FMPA 10
> WinXp
>
> I know this has come up before but I could not find it on the archives, I
> have a global text field full of text lines with carriage return at the end
> of each line. I would like to turn each line into a record.
> Can someone help with the script. Much appreciated.
>
> Regards
> Salman


_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Salman Maidan-3

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
In reply to this post by Lorne & Joan Walton
Thanks Lorne & Joan,

Worked perfect, just didnt know how to exit the loop how would you do "Exit
Loop If ( you've used up your "globalField" )"

On Thu, Jul 2, 2009 at 8:00 PM, Lorne & Joan Walton <[hidden email]>wrote:

> A looping script with something like:
>
> Set Variable ( $n ; 1 )
> Loop
>  New Record
>  Set Field ( Yourfield ; GetValue ( globalField ) ; $n ) )
>  Set Variable ( $n ; $n+1 )
>  Exit Loop If ( you've used up your "globalField" )
> End Loop
>
> ...would seem the quick and dirty method. Is there a better way?
>
>
> On Jul 2, 2009, at 9:43 AM, Salman Maidan wrote:
>
>  I know this has come up before but I could not find it on the archives, I
>> have a global text field full of text lines with carriage return at the
>> end
>> of each line. I would like to turn each line into a record.
>> Can someone help with the script. Much appreciated.
>>
>
> --
> Don't sweat the petty stuff. And don't pet the sweaty stuff.
>  Lorne Walton, Maple Ridge, BC, Canada 
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>



--
Salman Maidan
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Salman Maidan-3

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
In reply to this post by Beverly Voth-2
Thanks Beverly, i will try that too.


On Thu, Jul 2, 2009 at 8:19 PM, Beverly Voth <[hidden email]> wrote:

> Salman, try the Export Field Contents. Then reimport the text file into a
> table. You should get the 'returns' as one record. You  can also get TABs
> in
> that export and it you don't have the same number of "tabs" per "line",
> then
> you may get a strange (or not even work) import.
>
> Beverly
>
>
> On 7/2/09 12:43 PM, "Salman Maidan" <[hidden email]> wrote in whole or
> in part:
>
> > Hi Experts
> >
> > FMPA 10
> > WinXp
> >
> > I know this has come up before but I could not find it on the archives, I
> > have a global text field full of text lines with carriage return at the
> end
> > of each line. I would like to turn each line into a record.
> > Can someone help with the script. Much appreciated.
> >
> > Regards
> > Salman
>
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>



--
Salman Maidan
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Lorne & Joan Walton

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
In reply to this post by Salman Maidan-3
The ValueCount function will tell you how many values exist in  
yourglobalfield. I would set a variable to this number, and use it as  
the comparison in your Exit Loop If ().

I like Bev's method. Let us know if it works for you.

On Jul 2, 2009, at 10:20 AM, Salman Maidan wrote:

> Worked perfect, just didnt know how to exit the loop how would you  
> do "Exit
> Loop If ( you've used up your "globalField" )"

--
Somebody's boring me. I think it's me. [Dylan Thomas]
Lorne Walton, Maple Ridge, BC, Canada

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
bfr00

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
In reply to this post by Salman Maidan-3

Set Variable ( $data ; yourGlobalField )


Loop
  Exit Loop If [ isEmpty( $data) ]
   New Record
  Set Field ( Yourfield ; GetValue ( $data ) ; 1 ) )
   Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) )

End Loop


 --
Bruce Robertson
Concise Design
FileMaker 9 Certified


_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
bfr00

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
>
> Set Variable ( $data ; yourGlobalField )
>
>
> Loop
>   Exit Loop If [ isEmpty( $data) ]
>    New Record
>   Set Field ( Yourfield ; GetValue ( $data ) ; 1 ) )
>    Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) )
>
> End Loop
>
>
>  --
> Bruce Robertson
> Concise Design
> FileMaker 9 Certified

Oops, don't forget Commit Record after Set Field.


_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Bart Bartholomay

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
In reply to this post by bfr00
Also remove the close-parens in the third line after Loop after the  
variable $data.

Bart

Bart Bartholomay
HAB Marketing
3725 8th Lane
Vero Beach, FL 32960
772.299.6352
http://HABMarketing.com



On Jul 2, 2009, at 1:58 PM, Bruce Robertson wrote:


Set Variable ( $data ; yourGlobalField )


Loop
  Exit Loop If [ isEmpty( $data) ]
   New Record
  Set Field ( Yourfield ; GetValue ( $data ) ; 1 ) )
   Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) )

End Loop


--
Bruce Robertson
Concise Design
FileMaker 9 Certified


_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Lorne & Joan Walton

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
In reply to this post by bfr00
Wouldn't it work just as well if there were a single Commit Records,  
after the end of the loop?

On Jul 2, 2009, at 11:25 AM, Bruce Robertson wrote:

>> Set Variable ( $data ; yourGlobalField )
>>
>>
>> Loop
>>  Exit Loop If [ isEmpty( $data) ]
>>   New Record
>>  Set Field ( Yourfield ; GetValue ( $data ) ; 1 ) )
>>   Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) )
>>
>> End Loop
>>
>>
>> --
>> Bruce Robertson
>> Concise Design
>> FileMaker 9 Certified
>
> Oops, don't forget Commit Record after Set Field.
>

--
Politics is the art of preventing people from taking part in affairs  
which properly concern them. [Paul Valery]
Lorne & Joan Walton, Maple Ridge, BC, Canada

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Patrick Neame-2

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
My experience is that you need to do it after each loop. I don't know  
why, it's just what I've observed.
On Jul 2, 2009, at 9:19 pm, Lorne & Joan Walton wrote:

> Wouldn't it work just as well if there were a single Commit Records,  
> after the end of the loop?
>
> On Jul 2, 2009, at 11:25 AM, Bruce Robertson wrote:
>
>>> Set Variable ( $data ; yourGlobalField )
>>>
>>>
>>> Loop
>>> Exit Loop If [ isEmpty( $data) ]
>>>  New Record
>>> Set Field ( Yourfield ; GetValue ( $data ) ; 1 ) )
>>>  Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) )
>>>
>>> End Loop
>>>
>>>
>>> --
>>> Bruce Robertson
>>> Concise Design
>>> FileMaker 9 Certified
>>
>> Oops, don't forget Commit Record after Set Field.
>>
>
> --
> Politics is the art of preventing people from taking part in affairs  
> which properly concern them. [Paul Valery]
> Lorne & Joan Walton, Maple Ridge, BC, Canada
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Jason L DeLooze

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
Patrick,

Given the structure of this snippet of code, each newly created record (except the last one) will be committed as a side-effect of the "New Record" step.  Therefore, Lorne is correct: a single "Commit Records/Requests" is all that is needed - and it will commit the last record.

On the other hand, placing a "Commit Records", as Bruce suggests, is a good design practice, in my opinion.  It explicitly tells the casual reader that we are done with this new record and want to save its contents.  It also saves the last new record, which is left open unless we follow Lorne's suggestion; otherwise, the last created record may be lost at some other point, depending on what happens later.  Therefore, the best course is to explicitly save each record as we are done with it.
===

Of course, I realize this is just a script snippet - not full blown well written code with the necessary error handling, trapping, etc.  Consider what would happen in this script as written if, for example, the records in the target table had either field or record validation added at a later time.  In other words, this script may work now, as written and tested, but could fail without warning if the record structure changed at a later time.

Again, I realize this is a script snippet expressing a basic concept, given with the expectation that the reader will use the _ideas expressed_ and incorporate them into their design with consideration for error handling.

Jason


On 7/2/09 at 9:51 PM +0100, Patrick Neame wrote:

> My experience is that you need to do it after each loop. I don't know why, it's just what I've observed.
> On Jul 2, 2009, at 9:19 pm, Lorne & Joan Walton wrote:
>
>> Wouldn't it work just as well if there were a single Commit Records, after the end of the loop?
>>
>> On Jul 2, 2009, at 11:25 AM, Bruce Robertson wrote:
>>
>>>> Set Variable ( $data ; yourGlobalField )
>>>>
>>>>
>>>> Loop
>>>> Exit Loop If [ isEmpty( $data) ]
>>>>  New Record
>>>> Set Field ( Yourfield ; GetValue ( $data ) ; 1 ) )
>>>>  Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) )
>>>>
>>>> End Loop
>>>>
>>>>
>>>> --
>>>> Bruce Robertson
>>>> Concise Design
>>>> FileMaker 9 Certified
>>>
>>> Oops, don't forget Commit Record after Set Field.
>>>
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
bfr00

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
In reply to this post by Bart Bartholomay
Actually there is both an extra and a missing close-paren.
Let's see if I do this right.
Should be:

Set Variable ( $data ; yourGlobalField )
Loop
  Exit Loop If [ isEmpty( $data) ]
  New Record
  Set Field ( Yourfield ; GetValue ( $data ) ; 1 )
  Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) ) )
End Loop

On Thu, Jul 2, 2009 at 12:19 PM, Bart Bartholomay<[hidden email]> wrote:

> Also remove the close-parens in the third line after Loop after the variable
> $data.
>
> Bart
>
> Bart Bartholomay
> HAB Marketing
> 3725 8th Lane
> Vero Beach, FL 32960
> 772.299.6352
> http://HABMarketing.com
>
>
>
> On Jul 2, 2009, at 1:58 PM, Bruce Robertson wrote:
>
>
> Set Variable ( $data ; yourGlobalField )
>
>
> Loop
>  Exit Loop If [ isEmpty( $data) ]
>  New Record
>  Set Field ( Yourfield ; GetValue ( $data ) ; 1 ) )
>  Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) )
>
> End Loop
>
>
> --
> Bruce Robertson
> Concise Design
> FileMaker 9 Certified
>
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Bart Bartholomay

Re: Turn Text lines with "Return" to Records

Reply Threaded More More options
Print post
Permalink
Yep, see it now after the ValueCount function.

Cheers,

Bart

Bart Bartholomay
HAB Marketing
3725 8th Lane
Vero Beach, FL 32960
772.299.6352
http://HABMarketing.com



On Jul 3, 2009, at 5:02 PM, Bruce Robertson wrote:

Actually there is both an extra and a missing close-paren.
Let's see if I do this right.
Should be:

Set Variable ( $data ; yourGlobalField )
Loop
  Exit Loop If [ isEmpty( $data) ]
  New Record
  Set Field ( Yourfield ; GetValue ( $data ) ; 1 )
  Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) ) )
End Loop

On Thu, Jul 2, 2009 at 12:19 PM, Bart  
Bartholomay<[hidden email]> wrote:

> Also remove the close-parens in the third line after Loop after the  
> variable
> $data.
>
> Bart
>
> Bart Bartholomay
> HAB Marketing
> 3725 8th Lane
> Vero Beach, FL 32960
> 772.299.6352
> http://HABMarketing.com
>
>
>
> On Jul 2, 2009, at 1:58 PM, Bruce Robertson wrote:
>
>
> Set Variable ( $data ; yourGlobalField )
>
>
> Loop
> Exit Loop If [ isEmpty( $data) ]
> New Record
> Set Field ( Yourfield ; GetValue ( $data ) ; 1 ) )
> Set Variable ( $data ; middleValues( $data; 2; valueCount( $data) )
>
> End Loop
>
>
> --
> Bruce Robertson
> Concise Design
> FileMaker 9 Certified
>
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au