Ok, talking new I just down loaded the C# free version I
found on MS
page. I have been out of programming for a while and am
trying to
develop a small application to read a pipe delimeted file.
Do some
string converstions then export to a grid system or
spreadsheet such as
Excel.
Below is the C code I've pulled so far as well as the basic
code I was
using a few days back. Thank you!
__________________________
using System;
using System.IO;
class Test
{
public static void Main()
{
try
{
// Create an instance of StreamReader to read
from a file.
// The using statement also closes the
StreamReader.
using (StreamReader sr = new
StreamReader("k:New_LessonsLearned.txt"))
{
String line;
// Read and display lines from the file
until the end
of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be
read:");
Console.WriteLine(e.Message);
}
}
}
__________ BASIC version below.
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
' Open an ASCII text file and read it
DIM A AS STRING
DIM B AS STRING
DIM c AS STRING
DIM I AS INTEGER
DIM d AS STRING
DIM Title AS STRING
DIM hl AS STRING
DIM Source AS STRING
DIM exlink AS STRING
OPEN "c:\Documents and
Settings\New_LessonsLearned.txt" FOR INPUT AS #1
OPEN "c:\Documents and Settings\tempascii.txt"
FOR OUTPUT AS #2
C$ = "|"
WHILE ISFALSE EOF(1)
LINE INPUT#1, a$
FOR I=1 TO LEN(a$)
IF MID$(A$,I,1) = c$ THEN PRINT #2, b$: b$ =
"" : ELSE b$ = b$
+ MID$(a$,I,1)
NEXT I
PRINT #2, b$ : b$=""
WEND
CLOSE #1
CLOSE #2
OPEN "c:\Documents and Settings\tempascii.txt"
FOR INPUT AS #1
OPEN "c:\Documents and
Settings\ascioutput.txt" FOR OUTPUT AS #2
WHILE ISFALSE EOF(1)
LINE INPUT#1, d$
hl$ =
LEFT$(d$,INSTR(d$,"//")+1) &
"10.xxxxx.130.67" &
MID$(d$,INSTR(d$,"//")+12)
LINE INPUT#1, Title
LINE INPUT#1, Source
LINE INPUT#1, exlink
PRINT #2, hl$ ;Title;Source;exlink
WEND
CLOSE #1
CLOSE #2
END FUNCTION
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharp googlegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribe googlegroups.com
For more options, visit this group at http://groups.
google.com/group/C_Sharp
-~----------~----~----~----~------~----~------~--~---
|