Click here to Skip to main content
15,889,281 members
Home / Discussions / C#
   

C#

 
AnswerRe: Load assembly dynamically and call methods Pin
Luc Pattyn2-Nov-10 4:20
sitebuilderLuc Pattyn2-Nov-10 4:20 
AnswerRe: Load assembly dynamically and call methods Pin
souidi abderrahman3-Nov-10 0:30
souidi abderrahman3-Nov-10 0:30 
QuestionChnaging connectionString and reloading it Pin
mrkeivan2-Nov-10 4:06
mrkeivan2-Nov-10 4:06 
AnswerRe: Chnaging connectionString and reloading it Pin
thatraja2-Nov-10 4:25
professionalthatraja2-Nov-10 4:25 
GeneralRe: Chnaging connectionString and reloading it Pin
mrkeivan2-Nov-10 4:34
mrkeivan2-Nov-10 4:34 
GeneralRe: Chnaging connectionString and reloading it Pin
jschell2-Nov-10 8:28
jschell2-Nov-10 8:28 
AnswerRe: Chnaging connectionString and reloading it Pin
alrosan4-Nov-10 8:18
alrosan4-Nov-10 8:18 
QuestionReading Data from a multi sequenced File Pin
MumbleB1-Nov-10 21:34
MumbleB1-Nov-10 21:34 
Hi Guys. I have a file with two sequences, Sequence A and a Sequence B. Sequence A only appears once in the file and Sequence B can appear once or multiple times in the file. See Sample data below:

<B{1:F01CODENNNNXXX1234897878}{2:O1011702100608COMCODEXXXXX81287520281006081802N}{4:<br />
:20:TESTINGFILE01<br />
:28D:1/1<br />
:50H:/12345678901<br />
TEST NAME<br />
ADDRESS1<br />
ADDRESS2<br />
ADDRESS3<br />
:30:101022<br />
:21:REFERENCE1<br />
:23E:OTHR/DMST<br />
:32B:ZAR5005,00<br />
:57A:CODEXXXX<br />
:59:/12345600002345678<br />
TEST NAME2<br />
ADDRESS1<br />
ADDRESS2<br />
ADDRESS3<br />
:21:REFERENCE2<br />
:23E:OTHR/DMST<br />
:32B:ZAR7005,00<br />
:57A:CODEAAAA<br />
:59:/12345657002345678<br />
TEST NAME3<br />
ADDRESS1<br />
ADDRESS2<br />
ADDRESS3<br />
:71A:OUR<br />
-}

The portion in Bold is Sequence A and the remainder is sequence B data.

As you can see by the "TAGS" the fields starting with ':', that there are multiple Sequence B data. I need a way to pick up the data for the multiple Sequence B records. Sequence B start with :21: and ends with :59: followed by the address details. I tried a straight forward StreamReader and then populating the data but my Steamreader always goes from top to bottom in my while loop. Sample below.
string inFile;
inFile = textBox1.Text;
StreamReader sr = new StreamReader(inFile);
string holdline;
int lineCount = 0;
int clientname = 0;
int creditname = 0;
while (!sr.EndOfStream)
{
    holdline = sr.ReadLine();

    if (holdline.Length > 4)
    {
        string tag = holdline.Substring(0, 4);
        string tag2 = holdline.Substring(0, 5);
        if (tag == "{1:F")
        {
            lblBIC1.Text = holdline.Substring(6, 8).Trim();
            lblClientBIC.Text = holdline.Substring(46, 8).Trim();
            lblMsgType.Text = "MT" + holdline.Substring(33, 3).Trim();
            lblDate.Text = holdline.Substring(36, 10).Trim();
            lblSWIFTRef.Text = holdline.Substring(58, 10).Trim();
        }

        if (tag == ":20:")
        {
            int results = holdline.Length - 4;
            lblA20.Text = holdline.Substring(4, results).Trim();
        }

        else if (tag2 == ":21R:")
        {
            int r1 = holdline.Length - 5;
            lblA20.Text = holdline.Substring(4, r1).Trim();
            lblA20.Refresh();
        }
        else if (tag2 == ":50H:")
        {
            int r3 = holdline.Length - 6;
            lblA50H.Text = holdline.Substring(6, r3).Trim();
            lblA50H.Refresh();
            clientname = lineCount;
        }

If I do things like this I end up overwriting the first Sequence B data with the second sequence B data. How can I capture both Sequence B data? Should I make use of "switch and case" statements instead?

Any advice would be greatly apreciated.
Excellence is doing ordinary things extraordinarily well.

AnswerRe: Reading Data from a multi sequenced File Pin
OriginalGriff1-Nov-10 22:17
mveOriginalGriff1-Nov-10 22:17 
GeneralRe: Reading Data from a multi sequenced File Pin
MumbleB2-Nov-10 1:57
MumbleB2-Nov-10 1:57 
AnswerRe: Reading Data from a multi sequenced File Pin
PIEBALDconsult2-Nov-10 3:22
mvePIEBALDconsult2-Nov-10 3:22 
AnswerRe: Reading Data from a multi sequenced File Pin
jschell2-Nov-10 8:32
jschell2-Nov-10 8:32 
QuestionTable control help Pin
saqib821-Nov-10 6:53
saqib821-Nov-10 6:53 
AnswerRe: Table control help Pin
Ravi Bhavnani1-Nov-10 7:47
professionalRavi Bhavnani1-Nov-10 7:47 
AnswerRe: Table control help Pin
Dr.Walt Fair, PE1-Nov-10 10:48
professionalDr.Walt Fair, PE1-Nov-10 10:48 
Questionproblem in deployment Pin
Shuaib wasif khan1-Nov-10 0:45
Shuaib wasif khan1-Nov-10 0:45 
AnswerRe: problem in deployment Pin
Vimalsoft(Pty) Ltd1-Nov-10 9:41
professionalVimalsoft(Pty) Ltd1-Nov-10 9:41 
AnswerRe: problem in deployment Pin
T M Gray1-Nov-10 11:51
T M Gray1-Nov-10 11:51 
GeneralRe: problem in deployment Pin
Shuaib wasif khan2-Nov-10 16:47
Shuaib wasif khan2-Nov-10 16:47 
QuestionTo insert Validation in DataGridView Pin
annie_bel31-Oct-10 23:53
annie_bel31-Oct-10 23:53 
AnswerRe: To insert Validation in DataGridView Pin
Shuaib wasif khan1-Nov-10 1:16
Shuaib wasif khan1-Nov-10 1:16 
GeneralMessage Removed Pin
1-Nov-10 1:33
annie_bel1-Nov-10 1:33 
GeneralRe: To insert Validation in DataGridView Pin
Shuaib wasif khan1-Nov-10 1:46
Shuaib wasif khan1-Nov-10 1:46 
GeneralRe: To insert Validation in DataGridView Pin
annie_bel1-Nov-10 2:09
annie_bel1-Nov-10 2:09 
GeneralRe: To insert Validation in DataGridView Pin
Shuaib wasif khan1-Nov-10 2:48
Shuaib wasif khan1-Nov-10 2:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.