Topic Options
#57050 - 05/20/19 06:13 PM Comma separated line separation
dstauder Offline
OL User

Registered: 06/28/02
Posts: 74
Loc: St. Louis, Missouri USA
Hello all,

I have a CSV file, Pipe Delimited '|', that contains up to three variables (Denial Reasons) found on Line 30. Sometimes there will be only 1 or 2 reasons.

Example:

|"Reason 1","Reason 2","Reason 3"|

I need to create a separation of these reasons and place them into a Local Variable or Job Info for each reason.

&Reason1 := "Reason 1"
&Reason2 := "Reason 2"
&Reason3 := "Reason 3"

Each reason is variable in length up to 256 characters each.

I want to place them into a bulleted text file for each reason.

* Reason 1 xxxxxxxxxx
* Reason 2 xxxxxxxxxxxxxxxxxxxx
* Reason 3 xxx

I have created a Local Variable called &MyArray to split the strings into an arraystring.

*************************************************************

define(&sData, string, '')
define(&i, integer, 0)
define(&MyArray, arraystring, '')

% Replace this by your data selection in your
% data. You'll have to add an extra '|' at the
% end for this to work.
&sData := (trim(@(30,1,1000))+',')

% This is similar to "split", in that it will
% take each values that are separated by the
% character we specify. It doesn't automatically
% convert it to an array, but it's easy to make it
% do so.
search(&sData, ',')
&MyArray[&i] := &sData
&i := &i + 1
endsearch()

% Loop through the array, show the various lines.
for(&i, 0, 1, length(&MyArray)-1)
set(&MyArray[0])= SetWatchInfo [7]
set(&MyArray[1])= SetWatchInfo [8]
set(&MyArray[2])= SetWatchInfo [9]
endfor()

**************************************************************

Here is an actual line from the CSV:

6234567|April 15, 2019|LTRACT105|ENV69W2|Bond 20||||ABC-21-72346-9135||||||||||ABC-19-21862-11729|1|Mary|Smith|3214 Main Street||Boulder|CO|80121|||"You are eligible for Medicare (including Medicare Part D).","Your copay for medication does not meet our program guidelines."|||||||||||||||||||||||||x|


I am trying to use the above PressTalk example to build the process in the design tool (PlanetPress v.7.6.2.9999). I have created the local Variable MyArray and have changed it to look for the comma.

Another possible solution would be to use the 'pos' search to find the commas but I don't think I can use pos(trim(@1,30,30,1, 1000)) to select more than 2 positions.

Any help would be appreciated.

Thank you in advance,

Dan

Top
#57058 - 05/21/19 02:27 PM Re: Comma separated line separation [Re: dstauder]
dstauder Offline
OL User

Registered: 06/28/02
Posts: 74
Loc: St. Louis, Missouri USA
To all,

I am using the Extract_Fields_Search_Loop.pp7 example to generate an array.

I have created a Global Variable "FieldsArray" with the parameters Variable Type = "Array - string" and Array Size = "3"

Next I created 3 Text Boxes and Grouped them.

I Named the Group = "GroupLine30" in Basic Attributes, under Repeat in Repeat Mode = "Line repeat", from line 1 to line 1, Repeat Choice = "Horizontal only, Iteration condition to =@(30,1,1000)<>'' and Condition to exit and overflow = False
Under PressTalk Before:

define(&i,integer,0)
define(&curLine, string, '')
&curLine := trimright(@(30,1,1000))+','
search(&curLine,',')
&FieldsArray[&i] := &curLine
&i := &i+1
endsearch()

In Text Box "Reason1" under Text in the Variables Tab I created a Local Variable = "Reason_One" and checked the Custom data selection with the String to display = &FieldsArray[0]. Once I had the local variable I used it in the text box to show "* Reason_One" as the variable. The "*" represents a bullet point.
I repeated the steps for Reason2 and Reason3 text boxes.

My result looks like this:

* You are eligible for Medicare (including Medicare Part D).
* Your copay for medication does not meet our program guidelines.
*

My issue is I want to create a condition for the text box when the FieldArray[1] and/or FieldArray[2] are empty to not show at show.

I tried to build a custom condition where if the FieldArray[1] value = '' to be (inverted)True result and not show the box at all.

It doesn't like the syntax.

Any assistance is much appreciated.

Thank you,
Dan

Top
#57072 - 05/27/19 12:56 PM Re: Comma separated line separation [Re: dstauder]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1926
Loc: Objectif Lune, Montreal, Qc
Your condition in the text box should simply read:
Code:
=not(&FieldArray[1]='')
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#57075 - 05/28/19 08:46 AM Re: Comma separated line separation [Re: dstauder]
dstauder Offline
OL User

Registered: 06/28/02
Posts: 74
Loc: St. Louis, Missouri USA
Philippe,

This does not work. It will not accept the syntax. The error is:

PTK0040: Type/syntax() "FieldArray[1]"

Do I need to put this in a PressTalk before in order for this to work?

Thank you,

Dan

Top
#57077 - 05/28/19 01:58 PM Re: Comma separated line separation [Re: dstauder]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1926
Loc: Objectif Lune, Montreal, Qc
I noticed my variable name is FieldArray whereas yours was FieldsArray. That might simply the problem.

In any event, here's the three steps you need to get this to work (with the variable now named FieldsArray):
  • Create a global string array variable named FieldsArray, initialized with 3 elements
  • Add a PlanetPress Talk object as the first object on your page, containing the same code you were already using (assuming that has proven to work with your data):
    Code:
    define(&i,integer,0)
    define(&curLine, string, '')
    &curLine := trimright(@(30,1,1000))+','
    search(&curLine,',')
      &FieldsArray[&i] := &curLine
      &i := &i+1
    endsearch()
    
  • Then, in each of your 3 conditional text boxes, use the appropriate condition:
    Code:
    =not(&FieldsArray[0]='')
    

    or
    Code:
    =not(&FieldsArray[1]='')
    

    or
    Code:
    =not(&FieldsArray[2]='')
    
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#57079 - 05/28/19 03:51 PM Re: Comma separated line separation [Re: dstauder]
dstauder Offline
OL User

Registered: 06/28/02
Posts: 74
Loc: St. Louis, Missouri USA
Philippe,

Thank you. I am sorry, I was using FieldArray[] not FieldsArray[] when I programmed the condition the first time. The devil is in the details as they say...

Thank you for your assistance. It is working properly now.

Cheers,
Dan

Top