Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: get certain parts from memo field Post Reply Post New Topic
<< Prev Page  of 2
Author Message
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 15 Dec 2011 at 8:53am
??
tText:= tText + Split({@ToText}, chr(10))[aArray];
not 100%
IP IP Logged
campagnolo_1
Newbie
Newbie


Joined: 13 Dec 2011
Online Status: Offline
Posts: 12
Quote campagnolo_1 Replybullet Posted: 15 Dec 2011 at 8:54am
Ever closer......of course I didn't pass the data to an array, that's why I only got one line. So I created the array and passed the data into it, but now how do I display "all" the lines? Right now I can only display one line ( [1], [2], [3], etc..).
How can I show all of it?
 
NumberVar iIndex := 1;
NumberVar aArray := 1;
StringVar Array tText;
Redim tText [{@lineCount}];
while iIndex <= {@lineCount} do
(
    local NumberVar aArray := 1;
    if InStr((Split(0'>{@ToText},chr(10))[aArray]),"--")>0 then
    tText[iIndex] := Mid((Split({@ToText},chr(10))[aArray]),(InStr((Split({@ToText},chr(10))[aArray]),"--"))+2) else
    tText[iIndex] := Split({@ToText}, chr(10))[aArray];
    aArray := aArray + 1;
    iIndex := iIndex + 1;
);
tText[1]
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 15 Dec 2011 at 9:07am

you can always create a variable, loop through the array one element at a time and then create a single text field.

 
so don't display TEXT1 but a new one, that is coalesced array
IP IP Logged
campagnolo_1
Newbie
Newbie


Joined: 13 Dec 2011
Online Status: Offline
Posts: 12
Quote campagnolo_1 Replybullet Posted: 15 Dec 2011 at 9:10am
I'm not quite following, comatt1. Could you give me some pseudo code maybe?
 
Thanks for the help by the way, I really appreciate it!
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 15 Dec 2011 at 9:42am

NumberVar iIndex2 := 1;
NumberVar ct := 1;

local StringVar tText2:='';
while IIndex2<= {@lineCount} do
{
tText2:=tText2+chr(10)+tText[iIndex2];
iIndex2:=iIndex2+1;
}
 
Ttext2;


Edited by comatt1 - 15 Dec 2011 at 9:43am
IP IP Logged
campagnolo_1
Newbie
Newbie


Joined: 13 Dec 2011
Online Status: Offline
Posts: 12
Quote campagnolo_1 Replybullet Posted: 15 Dec 2011 at 11:47am
I see, makes sense of course. I had found a simpler way by using "join", but a couple of the lines don't align all the way left, so I will give your suggestion a try. Unfortunately now I'm getting a strange error after refreshing the data in the report: "A subscript must be between 1 and the size of the array." 
It seems to have to do with the aArray variable because it highlights this line: "if InStr((Split({@ToText},chr(10)) [aArray]),"NO")>0 then". I have tried making all the arrays static, but without success. More investigating tomorrow!
 
global NumberVar iIndex := 1;
global NumberVar aArray := 1;
global StringVar Array tText;
Redim tText [{@lineCount}];
while iIndex <= {@lineCount} do
(
    if InStr((Split({@ToText},chr(10)) [aArray]),"NO")>0 then
    tText[iIndex] := "" else
    if InStr((Split(0'>{@ToText},chr(10))[aArray]),"--")>0 then
    tText[iIndex] := Mid((Split({@ToText},chr(10))[aArray]),(InStr((Split({@ToText},chr(10))[aArray]),"--"))+2) else 
    tText[iIndex] := Split({@ToText}, chr(10))[aArray];
    aArray := aArray + 1;
    iIndex := iIndex + 1;
);
join(tText)


Edited by campagnolo_1 - 16 Dec 2011 at 6:38am
IP IP Logged
campagnolo_1
Newbie
Newbie


Joined: 13 Dec 2011
Online Status: Offline
Posts: 12
Quote campagnolo_1 Replybullet Posted: 19 Dec 2011 at 7:08am
Ok,
 
after another day of banging my head against the wall and scouring through forums I have to say that I'm at the end of my witts.
Just to recap real quick as to what I'm trying to do:
1. I have a memo field that I converted to Text.
2. I want to go through this text field create an array that holds the values for each line of this text field.
3. Then I want to go through the created array line by line (value by value) and check for the following conditions:
a) If there is a "No" in the line show a blank line " ".
b) If there is a "--" in the line, split the line at "--" and only show everything to the right of "--" until the chr(13)
c)If neither of the two previous conditions are met, just show the line.
4. The result of each condition gets put into a second array and then shown in the report.
 
Here is my (new) code that I created:
 
shared NumberVar x := 1;
shared NumberVar Array lLength := {@lineCount};
shared NumberVar arrLen := UBound(lLength);
shared StringVar Array mMemo;
Redim mMemo [arrLen];
shared StringVar Array tText;
Redim tText [arrLen];
while x <= arrLen Do
(
    mMemo := Split({@ToText}, chr(10)[x]);
    if InStr(mMemo[x],"NO") > 0 then
    tText[x] := "" else
    if InStr(mMemo[x],"--") > 0 then
    tText[x] := Mid(mMemo[x],(InStr(mMemo[x],"--"))+2) else
    tText[x] := mMemo[x];
    x := x + 1;
);
join(tText);
 
Help!
 
(Thank you!)
 
All I get now is the very first line of the array.
IP IP Logged
campagnolo_1
Newbie
Newbie


Joined: 13 Dec 2011
Online Status: Offline
Posts: 12
Quote campagnolo_1 Replybullet Posted: 20 Dec 2011 at 4:23am
And here it is:
 
shared NumberVar x := 1;
shared NumberVar arrLen := {@lineCount};
shared StringVar Array mMemo;
Redim mMemo [arrLen];
shared StringVar Array tText;
Redim tText [arrLen];
mMemo := Split({@ToText}, chr(10));
while x <= arrLen Do
(
   
    if InStr(mMemo[x],"NO") > 0 then
        tText[x] := ""
    else if InStr(mMemo[x],"--") > 0 then
        tText[x] := Mid(mMemo[x],(InStr(mMemo[x],"--"))+2)
    else
        tText[x] := mMemo[x];
    x := x + 1;
);
join(tText);
 
My mMemo array declaration (or rather the way I tried to fill it) was off.
Thanks comatt1 for all your help and guidance!
This problem is solved!
 
IP IP Logged
<< Prev Page  of 2
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.066 seconds.