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