|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hallo All!
I have to develop a Visual basic program that will read in a file of the following format #1=DIRECTION('',(0.E0,-1.E0,0.E0)); #2=VECTOR('',#1,1.E1); #3=CARTESIAN_POINT('',(0.E0,0.E0,0.E0)); For those who dont know, its a STEP file, used as a Data Exchange format. The Problem is that most of these Handles use references to each other. For example VECTOR refers to #1 which is DIRECTION. The flow of referencing being upwards ie #2 refers to #1 and #4 to #2 and so on. I am stymied, the file is Flat in nature, where ';' may be taken as the delimiter. Another thing, the whole file is not more than 300 lines. What would be the best strategy to deal with this kind of situation? How can it be resolved? Any help would be greatly appreciated! Thanks Pete |
|
#2
|
||||
|
||||
|
see if this helps, if it's just a plain text file, then it shouldn't be too hard
http://forums.devshed.com/t103230/s.html
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
|||
|
|||
|
changing the delimiter in input #filenumber
Thanks fisherman!
The problem I am facing is that the delimiter in my case is a Semicolon. I wonder if there is a way to modify the code given to reflect the new delimiter, since there are a lot of commas in the file, eg #65=B_SPLINE_SURFACE_WITH_KNOTS('',1,1,((#61,#62),(#63,#64)),.UNSPECIFIED.,.U., .U.,.F.,(2,2),(2,2),(-2.E-1,1.02E1),(-1.02E1,2.E-1),.UNSPECIFIED.); So stumped again! ![]() Pete |
|
#4
|
||||
|
||||
|
ok, try this - instead of reading the line of text into individual variables - read a whole line of text into one variable, then use the split() function to separate that line of text based on your delimiter, into an array variable - like so
Code:
Private Sub Form_Load()
Dim strLine As String
Dim strArray() As String
Dim i As Integer
Open App.Path & "\MyText.txt" For Input As #1
Do Until EOF(1)
strLine = Input(LOF(1), #1)
Loop
Close #1
strArray = Split(strLine, ",")
For i = 0 To UBound(strArray)
MsgBox strArray(i)
Next i
End Sub
Try using that code - establish a file in your directory that correlates to the name in the open statement - You can change your delimiter in the split function - it can be any recognized character. good luck |
|
#5
|
|||
|
|||
|
excellent man! Thanks, works like a charm.. i was using another statement
Line Input #1, but this works better, since the semicolons have been stripped off without extra code! Thanks mate! |
|
#6
|
||||
|
||||
|
glad I could be of service
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Reading a cross linked peculiar file into the Program |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|