[BR_forum] BR 4.2: STR2MAT and MAT2STR

General development discussion.

Moderators: Susan Smith, admin, Gabriel

Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by Susan Smith »

Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR 4.2? I looked at George's sample program for STR2MAT on the conference flash drive, and although I can follow it, I guess I'm still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files or to parse CSV lines into an array, but I don't seem to be able to get that working. Perhaps that's not what it's designed for. It seems like a valuable feature if only I could figure out why you'd use it.

-- Susan
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by Susan Smith »

Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV files be specifying a comma as a delimiter (didn't know I could) do that: MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into an array with STR2MAT. I tried to use a comma as the delimiter, and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an option to use encapsulation characters such as quotes (") around each element. Then you could effectively take an address or name that has a comma embedded in it such as Adam Smith, Jr. or Sierra Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when going back and forth. STR2MAT could have the option to STRIP an encapsulation character and MAT2STR could ADD the encapsulation character.

The result would be:
MAT2STR$(MAT ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions for this (the ones in my disorganized libraries).

-- Susan



Susan Smith wrote:
Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR 4.2? I looked at George's sample program for STR2MAT on the conference flash drive, and although I can follow it, I guess I'm still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files or to parse CSV lines into an array, but I don't seem to be able to get that working. Perhaps that's not what it's designed for. It seems like a valuable feature if only I could figure out why you'd use it.

-- Susan
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by John »

admin please delete this entry
Last edited by John on Thu Jun 17, 2010 7:16 am, edited 1 time in total.
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by Susan Smith »

John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm trying to do. I really don't know anything about them - yet. So I'd hate to update the wiki with bad information. I'm hoping that Gordon or perhaps the person who asked for that feature (or someone else who is using it) can shed some more light on it's purpose.

-- Susan


John Bowman wrote:
if you figrue it out please update it on the wiki - we need a page titled Mat2Str and another titled Str2Mat. usually what i do in these cases is make the pages, cut and paste the text from the release notes [[4.20]] and then in the release notes just leave something simple like "[[Str2Mat]] and [[Mat2Str]] introduced."

-john



On Sun, May 10, 2009 at 11:12 AM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV files be specifying a comma as a delimiter (didn't know I could) do that: MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into an array with STR2MAT. I tried to use a comma as the delimiter, and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an option to use encapsulation characters such as quotes (") around each element. Then you could effectively take an address or name that has a comma embedded in it such as Adam Smith, Jr. or Sierra Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when going back and forth. STR2MAT could have the option to STRIP an encapsulation character and MAT2STR could ADD the encapsulation character.

The result would be:
MAT2STR$(MAT ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions for this (the ones in my disorganized libraries).

-- Susan



Susan Smith wrote:
Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR 4.2? I looked at George's sample program for STR2MAT on the conference flash drive, and although I can follow it, I guess I'm still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files or to parse CSV lines into an array, but I don't seem to be able to get that working. Perhaps that's not what it's designed for. It seems like a valuable feature if only I could figure out why you'd use it.

-- Susan





_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net



_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by John »

admin please delete this entry
Last edited by John on Thu Jun 17, 2010 7:15 am, edited 1 time in total.
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by John »

admin please delete this entry
Last edited by John on Thu Jun 17, 2010 7:15 am, edited 1 time in total.
Susan Smith
Posts: 717
Joined: Sun Aug 10, 2008 4:24 am
Location: Southern California

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by Susan Smith »

Oh, don't kid yourself. I'm not USING the new features yet...or even 4.2. I'm just playing a bit to try to determine what my client's next upgrade path should be. I'm not even using GUI or NWP really. We went straight from 4.03 to 4.17 GUI using a non-proportional font, but no GUI controls. I'm not taking advantage of ANY new features yet - or even many old ones. But that is changing now that my client is finally interested. They may not be willing to finance it (this is a custom system), but I'm considering just doing it myself (mostly) so I don't get stuck in "yesterday" forever. It's never too late, right?

-- Susan

John Bowman wrote:
i'm kinda envious that you're using the newest features that I'm not using yet... hmmm, where's my remote desktop connection to the office...

:)
-john

On Sun, May 10, 2009 at 1:19 PM, John Bowman <gothnerd@gmail.com (gothnerd@gmail.com)> wrote:
don't fear using the wiki. if you add wrong information it will be as though it corrects itself (because i or someone else will be helping). just do your best. don't be afraid to try.

On Sun, May 10, 2009 at 1:11 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm trying to do. I really don't know anything about them - yet. So I'd hate to update the wiki with bad information. I'm hoping that Gordon or perhaps the person who asked for that feature (or someone else who is using it) can shed some more light on it's purpose.

-- Susan


John Bowman wrote:


John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by John »

admin please delete this entry
Last edited by John on Thu Jun 17, 2010 7:16 am, edited 2 times in total.
George Tisdale

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by George Tisdale »

I expect that you will find more uses for this function when we start parsing XML files. For the time being don’t worry about it unless you have a real need.

George L. Tisdale, CPA
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585
IRS Circular 230 Notice: "To ensure compliance with requirements imposed by the IRS, we inform you that any U.S. tax advice contained in this communication (including any attachments) is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding penalties under the Internal Revenue Code or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein."
This electronic message transmission contains information which is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination or distribution of this communication to other than the intended recipient is strictly prohibited. If you have received this communication in error, please notify us immediately by calling (978) 369-5585 or by electronic mail (gtisdale@tisdalecpa.com) Thank you.

From: br_forum-bounces@ads.net [mailto:br_forum-bounces@ads.net] On Behalf Of John Bowman
Sent: Sunday, May 10, 2009 1:43 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR


it's not too late at all! use source safe or some other Version Control System and go head long into it... if you *can't* make it work for some reason, just roll back to where you need to. check in and check out often.

(you typed it first, you use it first, you definately got me beat on this one, but yea i did get 4.1 before you)

:)
-john
On Sun, May 10, 2009 at 1:28 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Oh, don't kid yourself. I'm not USING the new features yet...or even 4.2. I'm just playing a bit to try to determine what my client's next upgrade path should be. I'm not even using GUI or NWP really. We went straight from 4.03 to 4.17 GUI using a non-proportional font, but no GUI controls. I'm not taking advantage of ANY new features yet - or even many old ones. But that is changing now that my client is finally interested. They may not be willing to finance it (this is a custom system), but I'm considering just doing it myself (mostly) so I don't get stuck in "yesterday" forever. It's never too late, right?

-- Susan


John Bowman wrote:
i'm kinda envious that you're using the newest features that I'm not using yet... hmmm, where's my remote desktop connection to the office...

:)
-john
On Sun, May 10, 2009 at 1:19 PM, John Bowman <gothnerd@gmail.com (gothnerd@gmail.com)> wrote:
don't fear using the wiki. if you add wrong information it will be as though it corrects itself (because i or someone else will be helping). just do your best. don't be afraid to try.

On Sun, May 10, 2009 at 1:11 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm trying to do. I really don't know anything about them - yet. So I'd hate to update the wiki with bad information. I'm hoping that Gordon or perhaps the person who asked for that feature (or someone else who is using it) can shed some more light on it's purpose.

-- Susan


John Bowman wrote:
if you figrue it out please update it on the wiki - we need a page titled Mat2Str and another titled Str2Mat. usually what i do in these cases is make the pages, cut and paste the text from the release notes [[4.20]] and then in the release notes just leave something simple like "[[Str2Mat]] and [[Mat2Str]] introduced."

-john



On Sun, May 10, 2009 at 11:12 AM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV files be specifying a comma as a delimiter (didn't know I could) do that: MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into an array with STR2MAT. I tried to use a comma as the delimiter, and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an option to use encapsulation characters such as quotes (") around each element. Then you could effectively take an address or name that has a comma embedded in it such as Adam Smith, Jr. or Sierra Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when going back and forth. STR2MAT could have the option to STRIP an encapsulation character and MAT2STR could ADD the encapsulation character.

The result would be:
MAT2STR$(MAT ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions for this (the ones in my disorganized libraries).

-- Susan




Susan Smith wrote:
Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR 4.2? I looked at George's sample program for STR2MAT on the conference flash drive, and although I can follow it, I guess I'm still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files or to parse CSV lines into an array, but I don't seem to be able to get that working. Perhaps that's not what it's designed for. It seems like a valuable feature if only I could figure out why you'd use it.

-- Susan
















_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by Gabriel »

I think CSV files is an excellent use for these functions.
 
I am constantly having problems with encapsulation characters in BR's reading of CSV files. Encapsulation characters have become a standard but BR doesn't handle them properly. I really wish it did. If they were able to add it to the STR2MAT functions then that would solve my problems.
 
 
While were at it, does anyone on the forum have functions for parsing and reading CSV files that they would like to share? We all know how fun it is to reinvent the wheel, but I'd rather skip that process if I can on this one.
 
 
Gabriel


On Sun, May 10, 2009 at 7:21 PM, George Tisdale <GTISDALE@tisdalecpa.com (GTISDALE@tisdalecpa.com)> wrote:

I expect that you will find more uses for this function when we start parsing XML files.  For the time being don’t worry about it unless you have a real need.
 
George L. Tisdale, CPA
Tisdale CPA
75 Junction Square Drive
Concord, MA  01742
(978) 369-5585
IRS Circular 230 Notice: "To ensure compliance with requirements imposed by the IRS, we inform you that any U.S. tax advice contained in this communication (including any attachments) is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding penalties under the Internal Revenue Code or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein."
This electronic message transmission contains information which is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination or distribution of this communication to other than the intended recipient is strictly prohibited. If you have received this communication in error, please notify us immediately by calling (978) 369-5585 or by electronic mail (gtisdale@tisdalecpa.com (gtisdale@tisdalecpa.com)) Thank you.
 
From: br_forum-bounces@ads.net (br_forum-bounces@ads.net) [mailto:br_forum-bounces@ads.net (br_forum-bounces@ads.net)] On Behalf Of John Bowman
Sent: Sunday, May 10, 2009 1:43 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR


 
it's not too late at all!  use source safe or some other Version Control System and go head long into it... if you *can't* make it work for some reason, just roll back to where you need to.  check in and check out often.

(you typed it first, you use it first, you definately got me beat on this one, but yea i did get 4.1 before you)

:)
-john
On Sun, May 10, 2009 at 1:28 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Oh, don't kid yourself. I'm not USING the new features yet...or even 4.2. I'm just playing a bit to try to determine what my client's next upgrade path should be. I'm not even using GUI or NWP really. We went straight from 4.03 to 4.17 GUI using a non-proportional font, but no GUI controls. I'm not taking advantage of ANY new features yet - or even many old ones. But that is changing now that my client is finally interested.  They may not be willing to finance it (this is a custom system), but I'm considering just doing it myself (mostly) so I don't get stuck in "yesterday" forever. It's never too late, right?

-- Susan


John Bowman wrote:
i'm kinda envious that you're using the newest features that I'm not using yet...   hmmm, where's my remote desktop connection to the office...

:)
-john
On Sun, May 10, 2009 at 1:19 PM, John Bowman <gothnerd@gmail.com (gothnerd@gmail.com)> wrote:
don't fear using the wiki.  if you add wrong information it will be as though it corrects itself (because i or someone else will be helping).  just do your best.  don't be afraid to try.
 
On Sun, May 10, 2009 at 1:11 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm trying to do. I really don't know anything about them - yet. So I'd hate to update the wiki with bad information. I'm hoping that Gordon or perhaps the person who asked for that feature (or someone else who is using it) can shed some more light on it's purpose.

-- Susan


John Bowman wrote:
if you figrue it out please update it on the wiki - we need a page titled Mat2Str and another titled Str2Mat.  usually what i do in these cases is make the pages, cut and paste the text from the release notes  [[4.20]] and then in the release notes just leave something simple like "[[Str2Mat]] and [[Mat2Str]] introduced."

-john



On Sun, May 10, 2009 at 11:12 AM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV files be specifying a comma as a delimiter (didn't know I could) do that:       MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into an array with STR2MAT. I tried to use a comma as the delimiter, and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an option to use encapsulation characters such as quotes (") around each element. Then you could effectively take an address or name that has a comma embedded in it  such as Adam Smith, Jr. or Sierra Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when going back and forth. STR2MAT could have the option to STRIP an encapsulation character and MAT2STR could ADD the encapsulation character.

The result would be:
MAT2STR$(MAT ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions for this (the ones in my disorganized libraries).

-- Susan




Susan Smith wrote:
Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR 4.2?  I looked at George's sample program for STR2MAT on the conference flash drive, and although I can follow it, I guess I'm still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files or to parse CSV lines into an array, but I don't seem to be able to get that working. Perhaps that's not what it's designed for. It seems like a valuable feature if only I could figure out why you'd use it.

-- Susan











 




_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net

 




_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by John »

For CSV you should be able to sue str2mat and then search through the array for unpaired encapsulation characters and combine that range of array items together, shift everything after it back and drop the excess items off the end.

-john

From: br_forum-bounces@ads.net [mailto:br_forum-bounces@ads.net] On Behalf Of Gabriel Bakker
Sent: Tuesday, May 12, 2009 12:48 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR


I think CSV files is an excellent use for these functions.



I am constantly having problems with encapsulation characters in BR's reading of CSV files. Encapsulation characters have become a standard but BR doesn't handle them properly. I really wish it did. If they were able to add it to the STR2MAT functions then that would solve my problems.





While were at it, does anyone on the forum have functions for parsing and reading CSV files that they would like to share? We all know how fun it is to reinvent the wheel, but I'd rather skip that process if I can on this one.





Gabriel

On Sun, May 10, 2009 at 7:21 PM, George Tisdale <GTISDALE@tisdalecpa.com (GTISDALE@tisdalecpa.com)> wrote:
I expect that you will find more uses for this function when we start parsing XML files. For the time being don’t worry about it unless you have a real need.

George L. Tisdale, CPA
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585
IRS Circular 230 Notice: "To ensure compliance with requirements imposed by the IRS, we inform you that any U.S. tax advice contained in this communication (including any attachments) is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding penalties under the Internal Revenue Code or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein."
This electronic message transmission contains information which is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination or distribution of this communication to other than the intended recipient is strictly prohibited. If you have received this communication in error, please notify us immediately by calling (978) 369-5585 or by electronic mail (gtisdale@tisdalecpa.com (gtisdale@tisdalecpa.com)) Thank you.

From: br_forum-bounces@ads.net (br_forum-bounces@ads.net) [mailto:br_forum-bounces@ads.net (br_forum-bounces@ads.net)] On Behalf Of John Bowman
Sent: Sunday, May 10, 2009 1:43 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR


it's not too late at all! use source safe or some other Version Control System and go head long into it... if you *can't* make it work for some reason, just roll back to where you need to. check in and check out often.

(you typed it first, you use it first, you definately got me beat on this one, but yea i did get 4.1 before you)

:)
-john
On Sun, May 10, 2009 at 1:28 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Oh, don't kid yourself. I'm not USING the new features yet...or even 4.2. I'm just playing a bit to try to determine what my client's next upgrade path should be. I'm not even using GUI or NWP really. We went straight from 4.03 to 4.17 GUI using a non-proportional font, but no GUI controls. I'm not taking advantage of ANY new features yet - or even many old ones. But that is changing now that my client is finally interested. They may not be willing to finance it (this is a custom system), but I'm considering just doing it myself (mostly) so I don't get stuck in "yesterday" forever. It's never too late, right?

-- Susan


John Bowman wrote:
i'm kinda envious that you're using the newest features that I'm not using yet... hmmm, where's my remote desktop connection to the office...

:)
-john
On Sun, May 10, 2009 at 1:19 PM, John Bowman <gothnerd@gmail.com (gothnerd@gmail.com)> wrote:
don't fear using the wiki. if you add wrong information it will be as though it corrects itself (because i or someone else will be helping). just do your best. don't be afraid to try.

On Sun, May 10, 2009 at 1:11 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm trying to do. I really don't know anything about them - yet. So I'd hate to update the wiki with bad information. I'm hoping that Gordon or perhaps the person who asked for that feature (or someone else who is using it) can shed some more light on it's purpose.

-- Susan


John Bowman wrote:
if you figrue it out please update it on the wiki - we need a page titled Mat2Str and another titled Str2Mat. usually what i do in these cases is make the pages, cut and paste the text from the release notes [[4.20]] and then in the release notes just leave something simple like "[[Str2Mat]] and [[Mat2Str]] introduced."

-john


On Sun, May 10, 2009 at 11:12 AM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV files be specifying a comma as a delimiter (didn't know I could) do that: MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into an array with STR2MAT. I tried to use a comma as the delimiter, and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an option to use encapsulation characters such as quotes (") around each element. Then you could effectively take an address or name that has a comma embedded in it such as Adam Smith, Jr. or Sierra Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when going back and forth. STR2MAT could have the option to STRIP an encapsulation character and MAT2STR could ADD the encapsulation character.

The result would be:
MAT2STR$(MAT ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions for this (the ones in my disorganized libraries).

-- Susan




Susan Smith wrote:
Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR 4.2? I looked at George's sample program for STR2MAT on the conference flash drive, and although I can follow it, I guess I'm still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files or to parse CSV lines into an array, but I don't seem to be able to get that working. Perhaps that's not what it's designed for. It seems like a valuable feature if only I could figure out why you'd use it.

-- Susan
















_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net







_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net
John Bowman
David Bohlke

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by David Bohlke »

Gabriel,

Here's one that I use whenever I'm dealing with a .CSV or tab delimited
file.

David Bohlke

Gabriel Bakker wrote:
I think CSV files is an excellent use for these functions.

I am constantly having problems with encapsulation characters in BR's
reading of CSV files. Encapsulation characters have become a standard
but BR doesn't handle them properly. I really wish it did. If they
were able to add it to the STR2MAT functions then that would solve my
problems.


While were at it, does anyone on the forum have functions for parsing
and reading CSV files that they would like to share? We all know how
fun it is to reinvent the wheel, but I'd rather skip that process if I
can on this one.


Gabriel

On Sun, May 10, 2009 at 7:21 PM, George Tisdale
<GTISDALE@tisdalecpa.com <mailto:GTISDALE@tisdalecpa.com>> wrote:

I expect that you will find more uses for this function when we
start parsing XML files. For the time being don’t worry about it
unless you have a real need.



*George L. Tisdale, CPA*
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585

IRS Circular 230 Notice: "To ensure compliance with requirements
imposed by the IRS, we inform you that any U.S. tax advice
contained in this communication (including any attachments) is not
intended or written to be used, and cannot be used, for the
purpose of (i) avoiding penalties under the Internal Revenue Code
or (ii) promoting, marketing or recommending to another party any
transaction or matter addressed herein."

This electronic message transmission contains information which is
intended only for the use of the individual or entity to which it
is addressed and may contain information that is privileged,
confidential and exempt from disclosure under applicable law. If
the reader of this message is not the intended recipient, you are
hereby notified that any dissemination or distribution of this
communication to other than the intended recipient is strictly
prohibited. If you have received this communication in error,
please notify us immediately by calling (978) 369-5585 or by
electronic mail (gtisdale@tisdalecpa.com
<mailto:gtisdale@tisdalecpa.com>) Thank you.



*From:* br_forum-bounces@ads.net <mailto:br_forum-bounces@ads.net>
[mailto:br_forum-bounces@ads.net
<mailto:br_forum-bounces@ads.net>] *On Behalf Of *John Bowman
*Sent:* Sunday, May 10, 2009 1:43 PM
*To:* Business Rules Forum
*Subject:* Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR



it's not too late at all! use source safe or some other Version
Control System and go head long into it... if you *can't* make it
work for some reason, just roll back to where you need to. check
in and check out often.

(you typed it first, you use it first, you definately got me beat
on this one, but yea i did get 4.1 before you)

:)
-john

On Sun, May 10, 2009 at 1:28 PM, Susan Smith
<susan@creativelyspeaking.net
<mailto:susan@creativelyspeaking.net>> wrote:

Oh, don't kid yourself. I'm not USING the new features yet...or
even 4.2. I'm just playing a bit to try to determine what my
client's next upgrade path should be. I'm not even using GUI or
NWP really. We went straight from 4.03 to 4.17 GUI using a
non-proportional font, but no GUI controls. I'm not taking
advantage of ANY new features yet - or even many old ones. But
that is changing now that my client is finally interested. They
may not be willing to finance it (this is a custom system), but
I'm considering just doing it myself (mostly) so I don't get stuck
in "yesterday" forever. It's never too late, right?

-- Susan



John Bowman wrote:

i'm kinda envious that you're using the newest features that I'm
not using yet... hmmm, where's my remote desktop connection to
the office...

:)
-john

On Sun, May 10, 2009 at 1:19 PM, John Bowman <gothnerd@gmail.com
<mailto:gothnerd@gmail.com>> wrote:

don't fear using the wiki. if you add wrong information it will
be as though it corrects itself (because i or someone else will be
helping). just do your best. don't be afraid to try.



On Sun, May 10, 2009 at 1:11 PM, Susan Smith
<susan@creativelyspeaking.net
<mailto:susan@creativelyspeaking.net>> wrote:

John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm
trying to do. I really don't know anything about them - yet. So
I'd hate to update the wiki with bad information. I'm hoping that
Gordon or perhaps the person who asked for that feature (or
someone else who is using it) can shed some more light on it's
purpose.

-- Susan


John Bowman wrote:

if you figrue it out please update it on the wiki - we need a page
titled Mat2Str and another titled Str2Mat. usually what i do in
these cases is make the pages, cut and paste the text from the
release notes [[4.20]] and then in the release notes just leave
something simple like "[[Str2Mat]] and [[Mat2Str]] introduced."

-john


On Sun, May 10, 2009 at 11:12 AM, Susan Smith
<susan@creativelyspeaking.net
<mailto:susan@creativelyspeaking.net>> wrote:

Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV
files be specifying a comma as a delimiter (didn't know I could)
do that: MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into
an array with STR2MAT. I tried to use a comma as the delimiter,
and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an
option to use encapsulation characters such as quotes (") around
each element. Then you could effectively take an address or name
that has a comma embedded in it such as Adam Smith, Jr. or Sierra
Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when
going back and forth. STR2MAT could have the option to STRIP an
encapsulation character and MAT2STR could ADD the encapsulation
character.

The result would be:
MAT2STR$(MAT ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions
for this (the ones in my disorganized libraries).

-- Susan





Susan Smith wrote:

Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR
4.2? I looked at George's sample program for STR2MAT on the
conference flash drive, and although I can follow it, I guess I'm
still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files
or to parse CSV lines into an array, but I don't seem to be able
to get that working. Perhaps that's not what it's designed for. It
seems like a valuable feature if only I could figure out why you'd
use it.

-- Susan




_______________________________________________
BR_forum mailing list
BR_forum@ads.net <mailto:BR_forum@ads.net>
http://ads.net/mailman/listinfo/br_forum_ads.net




_______________________________________________
BR_forum mailing list
BR_forum@ads.net <mailto:BR_forum@ads.net>
http://ads.net/mailman/listinfo/br_forum_ads.net


------------------------------------------------------------------------

_______________________________________________
BR_forum mailing list
BR_forum@ads.net
http://ads.net/mailman/listinfo/br_forum_ads.net
00100 dim A$*1000,B$(10)*100
00200 option base 1
00210 ! In Actual Usage You Would Read A Record From A File Or Do Linput From A Display File Into Variable A$ (Or Whatever You Want To Call It), But For Demonstration Purposes I Have Just Assigned A Value To Variable A$ To Demonstrate That It Will Parse Values With Quote Marks Or Without
00300 let A$='"abc","def","ghi,jkl",mno,pqr'
00400 let Z=FN_PARSE(A$,MAT B$,",") !For a comma delimited file
00410 ! ! Let Z=Fn_Parse(A$,Mat B$,Chr$(9)) !For A Tab Delimited File
00500 print Z,MAT B$
90001 ! ------------------------------------------------------------------
90002 def FN_PARSE(FFA$*2000,MAT FFB$,FFDELIM$;FTRIM$)
90003 ! Arguments Passed Are: 1)Record To Be Parsed 2)Array To Parse It Into 3)The Delimiter Between Elements 4)Optionally "T" If Elements Are To Be Trimmed
90004 ! Passes Back Number Of Highest Element Parsed
90005 if FFA$(LEN(FFA$):LEN(FFA$))<>FFDELIM$ then let FFA$=FFA$&FFDELIM$
90006 let FFA$=SREP$(FFA$,'"'&FFDELIM$&'"',CHR$(253)&CHR$(254)&CHR$(255))
90007 let FFA$=SREP$(FFA$,'""',CHR$(251)&CHR$(252))
90008 let FFA$=SREP$(FFA$,CHR$(253)&CHR$(254)&CHR$(255),'"'&FFDELIM$&'"')
90009 mat FFB$=("")
90010 let FF1=FF2=FF3=FF4=FQ2=0
90011 Loop1: !
90012 let FF1T=FF1
90013 Loop2: !
90014 let FF2=POS(FFA$,FFDELIM$,FF1T+1)
90015 if FFA$(FF1T+1:FF1T+1)='"' then
90016 let FF2=POS(FFA$,'"'&FFDELIM$,FF1T+1)+1
90017 end if
90018 let FQ1=POS(FFA$,'"',FF1T+1)
90019 if FQ1>0 AND FQ1<FF2 then
90020 let FQ2=POS(FFA$,'"',FQ1+1)
90021 if FQ2>FF2 then let FF1T=FQ2: goto Loop2
90022 end if
90023 if FF2<1 then goto Done1
90024 let FF3+=1
90025 if FF3>UDIM(FFB$) then let FF3-=1: goto Done1
90026 let FFB$(FF3)=FFA$(FF1+1:FF2-1)
90027 let FFLEN=LEN(FFB$(FF3))
90028 if FFB$(FF3)(1:1)='"' AND FFB$(FF3)(FFLEN:FFLEN)='"' then let FFB$(FF3)=FFB$(FF3)(2:FFLEN-1)
90029 if FFB$(FF3)=CHR$(251)&CHR$(252) then let FFB$(FF3)=""
90030 let FFB$(FF3)=SREP$(FFB$(FF3),CHR$(251)&CHR$(252),'"')
90031 if FTRIM$="T" then let FFB$(FF3)=TRIM$(FFB$(FF3))
90032 if LEN(FFB$(FF3))>0 then let FF4=FF3
90033 let FF1=FF2
90034 goto Loop1
90035 Done1: !
90036 let FN_PARSE=FF4
90037 fnend

_______________________________________________
BR_forum mailing list
BR_forum@ads.net
http://ads.net/mailman/listinfo/br_forum_ads.net
George Tisdale

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by George Tisdale »

On the thumb drive from this year and last year's conferences in the
tests directory there is a program that parses TAB delimited files that
have a header row. PARSE.wb Menu option under Test Programs/File
IO/Parse a text file

It takes a while to parse the sample file provided because

The sample file contains about 35000 records
The program reads the entire file to determine which fields are numeric
and which character
It determines the maximum length of each filed
Builds a file layout record and prints it
Reads the entire file and exports it to a BR internal file.

A progress bar indicates the progress through the file.

George L. Tisdale, CPA
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585



-----Original Message-----
From: br_forum-bounces@ads.net [mailto:br_forum-bounces@ads.net] On
Behalf Of David Bohlke
Sent: Tuesday, May 12, 2009 5:32 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR

Gabriel,

Here's one that I use whenever I'm dealing with a .CSV or tab delimited
file.

David Bohlke

Gabriel Bakker wrote:
I think CSV files is an excellent use for these functions.

I am constantly having problems with encapsulation characters in BR's
reading of CSV files. Encapsulation characters have become a standard
but BR doesn't handle them properly. I really wish it did. If they
were able to add it to the STR2MAT functions then that would solve my
problems.


While were at it, does anyone on the forum have functions for parsing
and reading CSV files that they would like to share? We all know how
fun it is to reinvent the wheel, but I'd rather skip that process if I
can on this one.


Gabriel

On Sun, May 10, 2009 at 7:21 PM, George Tisdale
<GTISDALE@tisdalecpa.com <mailto:GTISDALE@tisdalecpa.com>> wrote:

I expect that you will find more uses for this function when we
start parsing XML files. For the time being don't worry about it
unless you have a real need.



*George L. Tisdale, CPA*
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585

IRS Circular 230 Notice: "To ensure compliance with requirements
imposed by the IRS, we inform you that any U.S. tax advice
contained in this communication (including any attachments) is not
intended or written to be used, and cannot be used, for the
purpose of (i) avoiding penalties under the Internal Revenue Code
or (ii) promoting, marketing or recommending to another party any
transaction or matter addressed herein."

This electronic message transmission contains information which is
intended only for the use of the individual or entity to which it
is addressed and may contain information that is privileged,
confidential and exempt from disclosure under applicable law. If
the reader of this message is not the intended recipient, you are
hereby notified that any dissemination or distribution of this
communication to other than the intended recipient is strictly
prohibited. If you have received this communication in error,
please notify us immediately by calling (978) 369-5585 or by
electronic mail (gtisdale@tisdalecpa.com
<mailto:gtisdale@tisdalecpa.com>) Thank you.



*From:* br_forum-bounces@ads.net <mailto:br_forum-bounces@ads.net>
[mailto:br_forum-bounces@ads.net
<mailto:br_forum-bounces@ads.net>] *On Behalf Of *John Bowman
*Sent:* Sunday, May 10, 2009 1:43 PM
*To:* Business Rules Forum
*Subject:* Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR



it's not too late at all! use source safe or some other Version
Control System and go head long into it... if you *can't* make it
work for some reason, just roll back to where you need to. check
in and check out often.

(you typed it first, you use it first, you definately got me beat
on this one, but yea i did get 4.1 before you)

:)
-john

On Sun, May 10, 2009 at 1:28 PM, Susan Smith
<susan@creativelyspeaking.net
<mailto:susan@creativelyspeaking.net>> wrote:

Oh, don't kid yourself. I'm not USING the new features yet...or
even 4.2. I'm just playing a bit to try to determine what my
client's next upgrade path should be. I'm not even using GUI or
NWP really. We went straight from 4.03 to 4.17 GUI using a
non-proportional font, but no GUI controls. I'm not taking
advantage of ANY new features yet - or even many old ones. But
that is changing now that my client is finally interested. They
may not be willing to finance it (this is a custom system), but
I'm considering just doing it myself (mostly) so I don't get stuck
in "yesterday" forever. It's never too late, right?

-- Susan



John Bowman wrote:

i'm kinda envious that you're using the newest features that I'm
not using yet... hmmm, where's my remote desktop connection to
the office...

:)
-john

On Sun, May 10, 2009 at 1:19 PM, John Bowman <gothnerd@gmail.com
<mailto:gothnerd@gmail.com>> wrote:

don't fear using the wiki. if you add wrong information it will
be as though it corrects itself (because i or someone else will be
helping). just do your best. don't be afraid to try.



On Sun, May 10, 2009 at 1:11 PM, Susan Smith
<susan@creativelyspeaking.net
<mailto:susan@creativelyspeaking.net>> wrote:

John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm
trying to do. I really don't know anything about them - yet. So
I'd hate to update the wiki with bad information. I'm hoping that
Gordon or perhaps the person who asked for that feature (or
someone else who is using it) can shed some more light on it's
purpose.

-- Susan


John Bowman wrote:

if you figrue it out please update it on the wiki - we need a page
titled Mat2Str and another titled Str2Mat. usually what i do in
these cases is make the pages, cut and paste the text from the
release notes [[4.20]] and then in the release notes just leave
something simple like "[[Str2Mat]] and [[Mat2Str]] introduced."

-john


On Sun, May 10, 2009 at 11:12 AM, Susan Smith
<susan@creativelyspeaking.net
<mailto:susan@creativelyspeaking.net>> wrote:

Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV
files be specifying a comma as a delimiter (didn't know I could)
do that: MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into
an array with STR2MAT. I tried to use a comma as the delimiter,
and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an
option to use encapsulation characters such as quotes (") around
each element. Then you could effectively take an address or name
that has a comma embedded in it such as Adam Smith, Jr. or Sierra
Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when
going back and forth. STR2MAT could have the option to STRIP an
encapsulation character and MAT2STR could ADD the encapsulation
character.

The result would be:
MAT2STR$(MAT
ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions
for this (the ones in my disorganized libraries).

-- Susan





Susan Smith wrote:

Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR
4.2? I looked at George's sample program for STR2MAT on the
conference flash drive, and although I can follow it, I guess I'm
still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files
or to parse CSV lines into an array, but I don't seem to be able
to get that working. Perhaps that's not what it's designed for. It
seems like a valuable feature if only I could figure out why you'd
use it.

-- Susan




_______________________________________________
BR_forum mailing list
BR_forum@ads.net <mailto:BR_forum@ads.net>
http://ads.net/mailman/listinfo/br_forum_ads.net




_______________________________________________
BR_forum mailing list
BR_forum@ads.net <mailto:BR_forum@ads.net>
http://ads.net/mailman/listinfo/br_forum_ads.net


----------------------------------------------------------------------
--

_______________________________________________
BR_forum mailing list
BR_forum@ads.net
http://ads.net/mailman/listinfo/br_forum_ads.net
_______________________________________________
BR_forum mailing list
BR_forum@ads.net
http://ads.net/mailman/listinfo/br_forum_ads.net
GomezL
Posts: 258
Joined: Wed Apr 29, 2009 5:51 am
Contact:

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by GomezL »

Context.Wb (Delivered on the FLASH Drive)


<![if !supportLists]>1. <![endif]>FNOPEN_CSV
<![if !supportLists]>a. <![endif]>Open the CSV file, determined the field names and delimiter type, Dimension “CSV_DATA$” to the correct number of fields.
<![if !supportLists]>2. <![endif]>FNGET_VAR$
<![if !supportLists]>a. <![endif]>SubProc FNGET_VAR$ will create local BR variable references so you can use them in your application.
<![if !supportLists]>3. <![endif]>Do
<![if !supportLists]>a. <![endif]>Linput #CSV_HANDLE:CSV_DATA$
<![if !supportLists]>b. <![endif]>FNPARSE_CSV
<![if !supportLists]> i. <![endif]>(This will convert csv_data$ into an array)
<![if !supportLists]>c. <![endif]>(Do Something)
<![if !supportLists]>4. <![endif]>loop


The nice thing about these functions is you get to use the “Familiar FILEIO” methodology.


FNPARSE_CSV is quite complex because it actually handles various “Strange Situations” including the “Unix CSV Format”. (x##)
If your file is tab delimited, it also handles things like respecting the “Single Quote” that excel likes to add to “Text Fields”.
It also has the ability to trim,rtrm or leave the spaces.

Feel free to simply add the CONTEXTCONTEXT.WB library to your application, and it should remain compatible as the library growsl.

This is the same library that demonstrated FNOPEN_SQL using SQLISAM provided by Mills Enterprise.

The chm contains lots of documentation, but this is what you want:


FNOPEN_CSV(CSV_HANDLE,CSV$*80,&CSV_DELIMITER$,MAT CSV_FIELDS$,MAT CSV_DATA$)

This function will open a CSV or TAB delimited file, use the assigned a file handle, and populate the Delimiter, Field Names & Data arrays.
Parameters:
  • CSV_HANDLE - The file handle to use for this file.
  • CSV$ - The file name for the CSV file.
  • CSV_DELIMITER$ - The delimiter found in the "CSV$" file.
  • MAT CSV_FIELDS$ - An array containing a list of field names (Re-Dimensioned by the function)
  • MAT CSV_DATA$ - An array containing the data array (Re-Dimensioned by the function)

Returns:
The number of fields in the array.
FNPARSE_CSV(LIST$*3072,MAT WORK$;SEPARATOR$,NOTRIM)

This function will take a line read via "LINPUT$", and parse the results into the WORK$ array.
Parameters:
  • LIST$ - The string to be parsed.
  • MAT WORK$ - The destination string array (Make the array can support the appropriate # of characters in the fields)
  • SEPARATOR$ - Optional parameter that defines the separator. (Use CHR$(9) for Tabs).
  • NOTRIM - Optional parameter that instructs the function to keep the spaces from the source (NOTRIM:=1)

Note: This function has some special advanced parsing that supports certain "advanced" CSV "" functions. These are documented somewhere in the CSV standard.
Returns:
The number of items parsed
FNGET_VAR$*128(UNQ$, MAT FIELDSC$, MAT FIELDSN$)

This function actually creates a "PROC FILE" to be executed by the calling program. Once you execute the proc, local variables will be created for use within your application. These variables are assigned automatically based on the "SQL Names" defined in the context database.
Parameters:
  • UNQ$ - Unique "Prefix" name to be used when creating the BR variables.
  • MAT FIELDSC$ - An Array Containing "Character" or String Variable Names.
  • MAT FIELDSN$ - An Array Containing "Numeric" Variable Names.

Returns:
The Name of a "temporary Proc" that will be executed by the calling program.
Example:
EXECUTE "PROC="&FNGET_VAR$(PREFIX$:="EMPLOYEE",MAT EMPLOYEE_FIELDSC$,MAT EMPLOYEE_FIELDSN$)
The above example will execute the procedure created by FNGET_VAR$. That procedure will assign variable such as the following.
  • EMPLOYEE_EMP_NAME
  • EMPLOYEE_EMP_ADDRESS
  • EMPLOYEE_EMP_ZIP

In order to use the "Name Field" within the application you would use the "DATA$" array as in the following example.
PRINT "Name=";employee_DATA$(EMPLOYEE_EMP_NAME)


Luis I. Gomez
GomezL@CollectionSoftware.com (GomezL@CollectionSoftware.com)
1-800-435-7257
Commercial Legal Software, Inc.
http://www.CollectionSoftware.com

From: br_forum-bounces@ads.net [mailto:br_forum-bounces@ads.net] On Behalf Of Gabriel Bakker
Sent: Tuesday, May 12, 2009 12:48 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR

I think CSV files is an excellent use for these functions.

I am constantly having problems with encapsulation characters in BR's reading of CSV files. Encapsulation characters have become a standard but BR doesn't handle them properly. I really wish it did. If they were able to add it to the STR2MAT functions then that would solve my problems.


While were at it, does anyone on the forum have functions for parsing and reading CSV files that they would like to share? We all know how fun it is to reinvent the wheel, but I'd rather skip that process if I can on this one.


Gabriel
On Sun, May 10, 2009 at 7:21 PM, George Tisdale <GTISDALE@tisdalecpa.com (GTISDALE@tisdalecpa.com)> wrote:
I expect that you will find more uses for this function when we start parsing XML files. For the time being don’t worry about it unless you have a real need.

George L. Tisdale, CPA
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585
IRS Circular 230 Notice: "To ensure compliance with requirements imposed by the IRS, we inform you that any U.S. tax advice contained in this communication (including any attachments) is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding penalties under the Internal Revenue Code or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein."
This electronic message transmission contains information which is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination or distribution of this communication to other than the intended recipient is strictly prohibited. If you have received this communication in error, please notify us immediately by calling (978) 369-5585 or by electronic mail (gtisdale@tisdalecpa.com (gtisdale@tisdalecpa.com)) Thank you.

From: br_forum-bounces@ads.net (br_forum-bounces@ads.net) [mailto:br_forum-bounces@ads.net (br_forum-bounces@ads.net)] On Behalf Of John Bowman
Sent: Sunday, May 10, 2009 1:43 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR

it's not too late at all! use source safe or some other Version Control System and go head long into it... if you *can't* make it work for some reason, just roll back to where you need to. check in and check out often.

(you typed it first, you use it first, you definately got me beat on this one, but yea i did get 4.1 before you)

:)
-john
On Sun, May 10, 2009 at 1:28 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Oh, don't kid yourself. I'm not USING the new features yet...or even 4.2. I'm just playing a bit to try to determine what my client's next upgrade path should be. I'm not even using GUI or NWP really. We went straight from 4.03 to 4.17 GUI using a non-proportional font, but no GUI controls. I'm not taking advantage of ANY new features yet - or even many old ones. But that is changing now that my client is finally interested. They may not be willing to finance it (this is a custom system), but I'm considering just doing it myself (mostly) so I don't get stuck in "yesterday" forever. It's never too late, right?

-- Susan


John Bowman wrote:
i'm kinda envious that you're using the newest features that I'm not using yet... hmmm, where's my remote desktop connection to the office...

:)
-john
On Sun, May 10, 2009 at 1:19 PM, John Bowman <gothnerd@gmail.com (gothnerd@gmail.com)> wrote:
don't fear using the wiki. if you add wrong information it will be as though it corrects itself (because i or someone else will be helping). just do your best. don't be afraid to try.

On Sun, May 10, 2009 at 1:11 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm trying to do. I really don't know anything about them - yet. So I'd hate to update the wiki with bad information. I'm hoping that Gordon or perhaps the person who asked for that feature (or someone else who is using it) can shed some more light on it's purpose.

-- Susan


John Bowman wrote:
if you figrue it out please update it on the wiki - we need a page titled Mat2Str and another titled Str2Mat. usually what i do in these cases is make the pages, cut and paste the text from the release notes [[4.20]] and then in the release notes just leave something simple like "[[Str2Mat]] and [[Mat2Str]] introduced."

-john
On Sun, May 10, 2009 at 11:12 AM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV files be specifying a comma as a delimiter (didn't know I could) do that: MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into an array with STR2MAT. I tried to use a comma as the delimiter, and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an option to use encapsulation characters such as quotes (") around each element. Then you could effectively take an address or name that has a comma embedded in it such as Adam Smith, Jr. or Sierra Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when going back and forth. STR2MAT could have the option to STRIP an encapsulation character and MAT2STR could ADD the encapsulation character.

The result would be:
MAT2STR$(MAT ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions for this (the ones in my disorganized libraries).

-- Susan




Susan Smith wrote:
Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR 4.2? I looked at George's sample program for STR2MAT on the conference flash drive, and although I can follow it, I guess I'm still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files or to parse CSV lines into an array, but I don't seem to be able to get that working. Perhaps that's not what it's designed for. It seems like a valuable feature if only I could figure out why you'd use it.

-- Susan


_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net


_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net
Attachments
Context.zip
(56.42 KiB) Downloaded 433 times
GomezL
Posts: 258
Joined: Wed Apr 29, 2009 5:51 am
Contact:

[BR_forum] BR 4.2: STR2MAT and MAT2STR

Post by GomezL »

I can’t seem to attach the CHM, but the WB is attached to this one.

Luis I. Gomez
GomezL@CollectionSoftware.com (GomezL@CollectionSoftware.com)
1-800-435-7257
Commercial Legal Software, Inc.
http://www.CollectionSoftware.com


From: br_forum-bounces@ads.net [mailto:br_forum-bounces@ads.net] On Behalf Of Luis I. Gomez
Sent: Wednesday, May 13, 2009 7:37 AM
To: Business Rules Forum
Subject: ***FILENAME*** Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR



Context.Wb (Delivered on the FLASH Drive)


<![if !supportLists]>1. <![endif]>FNOPEN_CSV
<![if !supportLists]>a. <![endif]>Open the CSV file, determined the field names and delimiter type, Dimension “CSV_DATA$” to the correct number of fields.
<![if !supportLists]>2. <![endif]>FNGET_VAR$
<![if !supportLists]>a. <![endif]>SubProc FNGET_VAR$ will create local BR variable references so you can use them in your application.
<![if !supportLists]>3. <![endif]>Do
<![if !supportLists]>a. <![endif]>Linput #CSV_HANDLE:CSV_DATA$
<![if !supportLists]>b. <![endif]>FNPARSE_CSV
<![if !supportLists]> i. <![endif]>(This will convert csv_data$ into an array)
<![if !supportLists]>c. <![endif]>(Do Something)
<![if !supportLists]>4. <![endif]>loop


The nice thing about these functions is you get to use the “Familiar FILEIO” methodology.


FNPARSE_CSV is quite complex because it actually handles various “Strange Situations” including the “Unix CSV Format”. (x##)
If your file is tab delimited, it also handles things like respecting the “Single Quote” that excel likes to add to “Text Fields”.
It also has the ability to trim,rtrm or leave the spaces.

Feel free to simply add the CONTEXTCONTEXT.WB library to your application, and it should remain compatible as the library growsl.

This is the same library that demonstrated FNOPEN_SQL using SQLISAM provided by Mills Enterprise.

The chm contains lots of documentation, but this is what you want:


FNOPEN_CSV(CSV_HANDLE,CSV$*80,&CSV_DELIMITER$,MAT CSV_FIELDS$,MAT CSV_DATA$)

This function will open a CSV or TAB delimited file, use the assigned a file handle, and populate the Delimiter, Field Names & Data arrays.
Parameters:
  • CSV_HANDLE - The file handle to use for this file.
  • CSV$ - The file name for the CSV file.
  • CSV_DELIMITER$ - The delimiter found in the "CSV$" file.
  • MAT CSV_FIELDS$ - An array containing a list of field names (Re-Dimensioned by the function)
  • MAT CSV_DATA$ - An array containing the data array (Re-Dimensioned by the function)

Returns:
The number of fields in the array.
FNPARSE_CSV(LIST$*3072,MAT WORK$;SEPARATOR$,NOTRIM)

This function will take a line read via "LINPUT$", and parse the results into the WORK$ array.
Parameters:
  • LIST$ - The string to be parsed.
  • MAT WORK$ - The destination string array (Make the array can support the appropriate # of characters in the fields)
  • SEPARATOR$ - Optional parameter that defines the separator. (Use CHR$(9) for Tabs).
  • NOTRIM - Optional parameter that instructs the function to keep the spaces from the source (NOTRIM:=1)

Note: This function has some special advanced parsing that supports certain "advanced" CSV "" functions. These are documented somewhere in the CSV standard.
Returns:
The number of items parsed
FNGET_VAR$*128(UNQ$, MAT FIELDSC$, MAT FIELDSN$)

This function actually creates a "PROC FILE" to be executed by the calling program. Once you execute the proc, local variables will be created for use within your application. These variables are assigned automatically based on the "SQL Names" defined in the context database.
Parameters:
  • UNQ$ - Unique "Prefix" name to be used when creating the BR variables.
  • MAT FIELDSC$ - An Array Containing "Character" or String Variable Names.
  • MAT FIELDSN$ - An Array Containing "Numeric" Variable Names.

Returns:
The Name of a "temporary Proc" that will be executed by the calling program.
Example:
EXECUTE "PROC="&FNGET_VAR$(PREFIX$:="EMPLOYEE",MAT EMPLOYEE_FIELDSC$,MAT EMPLOYEE_FIELDSN$)
The above example will execute the procedure created by FNGET_VAR$. That procedure will assign variable such as the following.
  • EMPLOYEE_EMP_NAME
  • EMPLOYEE_EMP_ADDRESS
  • EMPLOYEE_EMP_ZIP

In order to use the "Name Field" within the application you would use the "DATA$" array as in the following example.
PRINT "Name=";employee_DATA$(EMPLOYEE_EMP_NAME)


Luis I. Gomez
GomezL@CollectionSoftware.com (GomezL@CollectionSoftware.com)
1-800-435-7257
Commercial Legal Software, Inc.
http://www.CollectionSoftware.com

From: br_forum-bounces@ads.net [mailto:br_forum-bounces@ads.net] On Behalf Of Gabriel Bakker
Sent: Tuesday, May 12, 2009 12:48 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR

I think CSV files is an excellent use for these functions.

I am constantly having problems with encapsulation characters in BR's reading of CSV files. Encapsulation characters have become a standard but BR doesn't handle them properly. I really wish it did. If they were able to add it to the STR2MAT functions then that would solve my problems.


While were at it, does anyone on the forum have functions for parsing and reading CSV files that they would like to share? We all know how fun it is to reinvent the wheel, but I'd rather skip that process if I can on this one.


Gabriel
On Sun, May 10, 2009 at 7:21 PM, George Tisdale <GTISDALE@tisdalecpa.com (GTISDALE@tisdalecpa.com)> wrote:
I expect that you will find more uses for this function when we start parsing XML files. For the time being don’t worry about it unless you have a real need.

George L. Tisdale, CPA
Tisdale CPA
75 Junction Square Drive
Concord, MA 01742
(978) 369-5585
IRS Circular 230 Notice: "To ensure compliance with requirements imposed by the IRS, we inform you that any U.S. tax advice contained in this communication (including any attachments) is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding penalties under the Internal Revenue Code or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein."
This electronic message transmission contains information which is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination or distribution of this communication to other than the intended recipient is strictly prohibited. If you have received this communication in error, please notify us immediately by calling (978) 369-5585 or by electronic mail (gtisdale@tisdalecpa.com (gtisdale@tisdalecpa.com)) Thank you.

From: br_forum-bounces@ads.net (br_forum-bounces@ads.net) [mailto:br_forum-bounces@ads.net (br_forum-bounces@ads.net)] On Behalf Of John Bowman
Sent: Sunday, May 10, 2009 1:43 PM
To: Business Rules Forum
Subject: Re: [BR_forum] BR 4.2: STR2MAT and MAT2STR

it's not too late at all! use source safe or some other Version Control System and go head long into it... if you *can't* make it work for some reason, just roll back to where you need to. check in and check out often.

(you typed it first, you use it first, you definately got me beat on this one, but yea i did get 4.1 before you)

:)
-john
On Sun, May 10, 2009 at 1:28 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Oh, don't kid yourself. I'm not USING the new features yet...or even 4.2. I'm just playing a bit to try to determine what my client's next upgrade path should be. I'm not even using GUI or NWP really. We went straight from 4.03 to 4.17 GUI using a non-proportional font, but no GUI controls. I'm not taking advantage of ANY new features yet - or even many old ones. But that is changing now that my client is finally interested. They may not be willing to finance it (this is a custom system), but I'm considering just doing it myself (mostly) so I don't get stuck in "yesterday" forever. It's never too late, right?

-- Susan


John Bowman wrote:
i'm kinda envious that you're using the newest features that I'm not using yet... hmmm, where's my remote desktop connection to the office...

:)
-john
On Sun, May 10, 2009 at 1:19 PM, John Bowman <gothnerd@gmail.com (gothnerd@gmail.com)> wrote:
don't fear using the wiki. if you add wrong information it will be as though it corrects itself (because i or someone else will be helping). just do your best. don't be afraid to try.

On Sun, May 10, 2009 at 1:11 PM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
John,

I'm not sure that MAT2STR and STR2MAT were designed to do what I'm trying to do. I really don't know anything about them - yet. So I'd hate to update the wiki with bad information. I'm hoping that Gordon or perhaps the person who asked for that feature (or someone else who is using it) can shed some more light on it's purpose.

-- Susan


John Bowman wrote:
if you figrue it out please update it on the wiki - we need a page titled Mat2Str and another titled Str2Mat. usually what i do in these cases is make the pages, cut and paste the text from the release notes [[4.20]] and then in the release notes just leave something simple like "[[Str2Mat]] and [[Mat2Str]] introduced."

-john
On Sun, May 10, 2009 at 11:12 AM, Susan Smith <susan@creativelyspeaking.net (susan@creativelyspeaking.net)> wrote:
Follow-up:
I DID get MAT2STR to create a line I could use for creating CSV files be specifying a comma as a delimiter (didn't know I could) do that: MAT2STR$(MAT a$,LONGLINE$,",")

But I can't do the reverse and parse a comma-delimited string into an array with STR2MAT. I tried to use a comma as the delimiter, and although it doesn't error, the array is not loaded.

ENCAPSULATION CHARACTER OPTION for STR2MAT and MAT2STR
Assuming that I get this working, it would be great to have an option to use encapsulation characters such as quotes (") around each element. Then you could effectively take an address or name that has a comma embedded in it such as Adam Smith, Jr. or Sierra Madre, CA and create "Adam Smith, Jr." or "Sierra Madre, CA" when going back and forth. STR2MAT could have the option to STRIP an encapsulation character and MAT2STR could ADD the encapsulation character.

The result would be:
MAT2STR$(MAT ARRAYNAME$,STRINGNAME$,DELIMITER$,ENCAPSULATION_CHAR$)

In the meantime, I'll continue to use my user-defined functions for this (the ones in my disorganized libraries).

-- Susan




Susan Smith wrote:
Hi all,

Can someone tell me what you'd use STR2MAT and MAT2STR for in BR 4.2? I looked at George's sample program for STR2MAT on the conference flash drive, and although I can follow it, I guess I'm still not sure what this function's purpose is.

I assumed that it could be used to create text lines for CSV files or to parse CSV lines into an array, but I don't seem to be able to get that working. Perhaps that's not what it's designed for. It seems like a valuable feature if only I could figure out why you'd use it.

-- Susan


_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net


_______________________________________________
BR_forum mailing list
BR_forum@ads.net (BR_forum@ads.net)
http://ads.net/mailman/listinfo/br_forum_ads.net
Attachments
CONTEXT.WB
(93.03 KiB) Downloaded 455 times
Post Reply