4 Replies - 202 Views - Last Post: 15 August 2015 - 06:30 AM Rate Topic: -----

#1 triplekkk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-August 15

how to list up and array the result from input file

Posted 14 August 2015 - 10:35 PM

hi I'm new in vb programming....i have write a script to read an input file, compute, array and then produce an output but i have a problem to list up and array an output....it's only print out the last output....can anybody help me....tq

the input file is something like this:

Quote

BELU 1 1 0.00096 56886.49983 0.00029
BELU 1 2 0.00015 56886.49983 0.00036
BELU 1 3 0.00514 56886.49983 0.00157
BELU 2 1 -0.00009 56887.49983 0.00029
BELU 2 2 -0.00134 56887.49983 0.00036
BELU 2 3 -0.00084 56887.49983 0.00153
BELU 3 1 -0.00211 56888.49983 0.00031
BELU 3 2 0.00077 56888.49983 0.00037
BELU 3 3 -0.00357 56888.49983 0.00167
BELU 4 1 0.00179 56889.49983 0.00031
BELU 4 2 -0.00043 56889.49983 0.00037
BELU 4 3 -0.00307 56889.49983 0.00165
BELU 5 1 0.00053 56890.49983 0.00030
BELU 5 2 0.00143 56890.49983 0.00036
BELU 5 3 -0.00138 56890.49983 0.00158
BELU 6 1 -0.00027 56891.49983 0.00029
BELU 6 2 -0.00004 56891.49983 0.00035
BELU 6 3 -0.00050 56891.49983 0.00153
BELU 7 1 -0.00076 56892.49983 0.00031
BELU 7 2 -0.00055 56892.49983 0.00037
BELU 7 3 0.00330 56892.49983 0.00166
KING 2 1 0.00356 56887.49983 0.00074
KING 2 2 -0.00127 56887.49983 0.00095
KING 2 3 0.03158 56887.49983 0.00525
KING 4 1 -0.00062 56889.49983 0.00067
KING 4 2 -0.00268 56889.49983 0.00073
KING 4 3 -0.00433 56889.49983 0.00458
KING 5 1 -0.00003 56890.49983 0.00044
KING 5 2 0.00101 56890.49983 0.00057
KING 5 3 -0.00198 56890.49983 0.00327
KING 6 1 -0.00209 56891.49983 0.00049
KING 6 2 0.00025 56891.49983 0.00057
KING 6 3 -0.00301 56891.49983 0.00349
KING 7 1 0.00049 56892.49983 0.00051
KING 7 2 0.00064 56892.49983 0.00065
KING 7 3 -0.00645 56892.49983 0.00342
KUDA 1 1 0.00167 56886.49983 0.00032
KUDA 1 2 -0.00004 56886.49983 0.00035
KUDA 1 3 -0.00269 56886.49983 0.00169
KUDA 2 1 -0.00003 56887.49983 0.00033
KUDA 2 2 -0.00024 56887.49983 0.00035
KUDA 2 3 -0.00001 56887.49983 0.00167
KUDA 3 1 -0.00204 56888.49983 0.00035
KUDA 3 2 0.00118 56888.49983 0.00038
KUDA 3 3 0.00080 56888.49983 0.00188
KUDA 4 1 -0.00289 56889.49983 0.00035
KUDA 4 2 0.00015 56889.49983 0.00039
KUDA 4 3 -0.00329 56889.49983 0.00182
KUDA 5 1 -0.00014 56890.49983 0.00032
KUDA 5 2 0.00022 56890.49983 0.00036
KUDA 5 3 -0.00360 56890.49983 0.00170
KUDA 6 1 0.00205 56891.49983 0.00031
KUDA 6 2 -0.00032 56891.49983 0.00034
KUDA 6 3 -0.00381 56891.49983 0.00166
KUDA 7 1 0.00091 56892.49983 0.00034
KUDA 7 2 -0.00068 56892.49983 0.00039
KUDA 7 3 0.01240 56892.49983 0.00183
MRDU 1 1 -0.00096 56886.49983 0.00030
MRDU 1 2 -0.00039 56886.49983 0.00035
MRDU 1 3 0.00262 56886.49983 0.00164
MRDU 2 1 -0.00124 56887.49983 0.00030
MRDU 2 2 -0.00069 56887.49983 0.00035
MRDU 2 3 0.00440 56887.49983 0.00163
MRDU 3 1 0.00033 56888.49983 0.00032
MRDU 3 2 0.00208 56888.49983 0.00037
MRDU 3 3 0.00380 56888.49983 0.00183
MRDU 4 1 0.00274 56889.49983 0.00032
MRDU 4 2 -0.00033 56889.49983 0.00037
MRDU 4 3 -0.00568 56889.49983 0.00179
MRDU 5 1 0.00074 56890.49983 0.00030
MRDU 5 2 -0.00019 56890.49983 0.00035
MRDU 5 3 0.00095 56890.49983 0.00169
MRDU 6 1 -0.00117 56891.49983 0.00029
MRDU 6 2 -0.00220 56891.49983 0.00034
MRDU 6 3 0.00039 56891.49983 0.00163
MRDU 7 1 -0.00025 56892.49983 0.00031
MRDU 7 2 0.00170 56892.49983 0.00037
MRDU 7 3 -0.00704 56892.49983 0.00179
MTAW 1 1 -0.00120 56886.49983 0.00035
MTAW 1 2 -0.00039 56886.49983 0.00037
MTAW 1 3 0.00193 56886.49983 0.00193
MTAW 2 1 0.00064 56887.49983 0.00046
MTAW 2 2 -0.00007 56887.49983 0.00055
MTAW 2 3 -0.00070 56887.49983 0.00269
MTAW 3 1 -0.00005 56888.49983 0.00039
MTAW 3 2 -0.00140 56888.49983 0.00040
MTAW 3 3 -0.00129 56888.49983 0.00227
MTAW 4 1 -0.00006 56889.49983 0.00037
MTAW 4 2 -0.00032 56889.49983 0.00039
MTAW 4 3 0.00185 56889.49983 0.00213
MTAW 5 1 0.00047 56890.49983 0.00035
MTAW 5 2 -0.00086 56890.49983 0.00038
MTAW 5 3 -0.00132 56890.49983 0.00207
MTAW 6 1 0.00053 56891.49983 0.00034
MTAW 6 2 0.00203 56891.49983 0.00036
MTAW 6 3 0.00328 56891.49983 0.00194
MTAW 7 1 -0.00030 56892.49983 0.00036
MTAW 7 2 0.00044 56892.49983 0.00038
MTAW 7 3 -0.00414 56892.49983 0.00202
RANA 1 1 0.00061 56886.49983 0.00028
RANA 1 2 -0.00074 56886.49983 0.00035
RANA 1 3 0.00210 56886.49983 0.00162
RANA 2 1 0.00009 56887.49983 0.00028
RANA 2 2 -0.00035 56887.49983 0.00035
RANA 2 3 0.00035 56887.49983 0.00157
RANA 3 1 0.00231 56888.49983 0.00030
RANA 3 2 -0.00052 56888.49983 0.00037
RANA 3 3 0.00149 56888.49983 0.00174
RANA 4 1 -0.00218 56889.49983 0.00030
RANA 4 2 -0.00032 56889.49983 0.00037
RANA 4 3 -0.00307 56889.49983 0.00173
RANA 5 1 -0.00005 56890.49983 0.00029
RANA 5 2 -0.00144 56890.49983 0.00036
RANA 5 3 -0.00313 56890.49983 0.00163
RANA 6 1 -0.00001 56891.49983 0.00028
RANA 6 2 0.00119 56891.49983 0.00035
RANA 6 3 0.00432 56891.49983 0.00159
RANA 7 1 -0.00056 56892.49983 0.00030
RANA 7 2 0.00202 56892.49983 0.00037
RANA 7 3 -0.00297 56892.49983 0.00172
SAND 1 1 -0.00190 56886.49983 0.00029
SAND 1 2 0.00092 56886.49983 0.00037
SAND 1 3 -0.00379 56886.49983 0.00190
SAND 2 1 0.00129 56887.49983 0.00029
SAND 2 2 0.00105 56887.49983 0.00039
SAND 2 3 -0.00183 56887.49983 0.00182
SAND 3 1 0.00136 56888.49983 0.00030
SAND 3 2 -0.00151 56888.49983 0.00039
SAND 3 3 -0.00025 56888.49983 0.00203
SAND 4 1 -0.00160 56889.49983 0.00032
SAND 4 2 -0.00015 56889.49983 0.00042
SAND 4 3 0.00429 56889.49983 0.00211
SAND 5 1 0.00119 56890.49983 0.00032
SAND 5 2 -0.00039 56890.49983 0.00039
SAND 5 3 0.01214 56890.49983 0.00206
SAND 6 1 -0.00070 56891.49983 0.00028
SAND 6 2 0.00044 56891.49983 0.00036
SAND 6 3 -0.00388 56891.49983 0.00188
SAND 7 1 0.00027 56892.49983 0.00030
SAND 7 2 -0.00051 56892.49983 0.00039
SAND 7 3 -0.00360 56892.49983 0.00199
SEMP 1 1 -0.00060 56886.49983 0.00033
SEMP 1 2 -0.00062 56886.49983 0.00040
SEMP 1 3 -0.00398 56886.49983 0.00183
SEMP 2 1 0.00077 56887.49983 0.00045
SEMP 2 2 0.00084 56887.49983 0.00059
SEMP 2 3 0.00098 56887.49983 0.00248
SEMP 3 1 -0.00149 56888.49983 0.00037
SEMP 3 2 -0.00054 56888.49983 0.00043
SEMP 3 3 0.00383 56888.49983 0.00210
SEMP 4 1 0.00118 56889.49983 0.00036
SEMP 4 2 -0.00041 56889.49983 0.00042
SEMP 4 3 0.01011 56889.49983 0.00199
SEMP 5 1 -0.00294 56890.49983 0.00034
SEMP 5 2 -0.00241 56890.49983 0.00040
SEMP 5 3 -0.00380 56890.49983 0.00193
SEMP 6 1 0.00075 56891.49983 0.00033
SEMP 6 2 0.00165 56891.49983 0.00038
SEMP 6 3 -0.00204 56891.49983 0.00181
SEMP 7 1 0.00216 56892.49983 0.00035
SEMP 7 2 0.00139 56892.49983 0.00041
SEMP 7 3 -0.00367 56892.49983 0.00191
UMSS 1 1 0.00134 56886.49983 0.00029
UMSS 1 2 0.00130 56886.49983 0.00038
UMSS 1 3 -0.00127 56886.49983 0.00182
UMSS 2 1 -0.00148 56887.49983 0.00029
UMSS 2 2 0.00080 56887.49983 0.00039
UMSS 2 3 -0.00236 56887.49983 0.00177
UMSS 3 1 0.00173 56888.49983 0.00031
UMSS 3 2 -0.00021 56888.49983 0.00040
UMSS 3 3 -0.00490 56888.49983 0.00191
UMSS 4 1 0.00148 56889.49983 0.00031
UMSS 4 2 0.00131 56889.49983 0.00041
UMSS 4 3 -0.00121 56889.49983 0.00197
UMSS 5 1 0.00014 56890.49983 0.00029
UMSS 5 2 0.00348 56890.49983 0.00040
UMSS 5 3 0.00006 56890.49983 0.00182
UMSS 6 1 -0.00110 56891.49983 0.00029
UMSS 6 2 -0.00262 56891.49983 0.00037
UMSS 6 3 0.00235 56891.49983 0.00178
UMSS 7 1 -0.00187 56892.49983 0.00030
UMSS 7 2 -0.00347 56892.49983 0.00039
UMSS 7 3 0.00576 56892.49983 0.00190


this is VB my script:

Option Explicit

Private Sub Command1_Click()

On Error GoTo ErrHandler
   CommonDialog1.InitDir = App.Path
   CommonDialog1.Filter = "Plot_Files (*.PLT)|*.PLT"
   CommonDialog1.FilterIndex = 1
   CommonDialog1.ShowOpen
   Text1.Text = CommonDialog1.FileName
   
ErrHandler:
   Exit Sub
End Sub

Private Sub Command2_Click()

Dim TSERIES As String
Dim iInputFile As Integer
Dim iOutputFile As Integer
Dim STN As String
Dim EPOK As String
Dim COMP As Integer
Dim RES As String
Dim SIG As String
Dim MJD, JD, a, b, C, d, e, f, Dy, Mn, Yr As Double
Dim DOY As String
Dim NORTH, EAST, UP, SIG_N, SIG_E, SIG_U As String
iInputFile = FreeFile
iOutputFile = FreeFile

Open CommonDialog1.FileName For Input As #iInputFile
    
    Do Until EOF(iInputFile)
          
          Line Input #iInputFile, TSERIES
                
          STN = Mid(TSERIES, 1, 4)
          EPOK = Mid(TSERIES, 20, 3)
          COMP = Mid(TSERIES, 23, 1)
          RES = Mid(TSERIES, 27, 7)
          MJD = Mid(TSERIES, 37, 11)
          SIG = Mid(TSERIES, 64, 7)
          
          If COMP = 1 Then
        NORTH = RES
        SIG_N = SIG
    End If
        If COMP = 2 Then
           EAST = RES
           SIG_E = SIG
                End If
                    If COMP = 3 Then
                        UP = RES
                        SIG_U = SIG
                      End If
                                                                                                                     
'Kiraan Modified Julian Date (MJD) to Day of Year (DOY)
JD = MJD + 2400000.5
a = Int(JD + 0.5)
If a < 2299161 Then
C = a + 1524
Else
b = Int((a - 1867216.25) / 36524.25)
C = a + b - Int(b / 4) + 1525
End If

d = Int((C - 122.1) / 365.25)
e = Int(365.25 * d)
f = Int((C - e) / 30.6001)

Dy = Int(C - e - Int(30.6001 * f) + (JD + 0.5) - a) 'Day of Month
Mn = f - 1 - 12 * Int(f / 14) 'Month of Year
Yr = d - 4715 - Int((7 + Mn) / 10) 'Year

DOY = Format(Int((275 * Mn) / 9) - 2 * Int((Mn + 9) / 12) + Dy - 30, "000") 'Day of Year
                         
    Loop
                                                                               
Close #iInputFile
         
    
If STN = "UMSS" Then

Open "d:\GNSS_PROGRAM\T_Plot\UMSS.txt" For Output As #iOutputFile

Print #iOutputFile, EPOK, STN, DOY, NORTH, EAST, UP,

Close #iOutputFile

End If
    
   
End Sub

This post has been edited by andrewsw: 15 August 2015 - 03:43 AM
Reason for edit:: Added [code][/code] tags, and quote tags


Is This A Good Question/Topic? 0
  • +

Replies To: how to list up and array the result from input file

#2 andrewsw  Icon User is offline

  • I'm not here to twist your niblets
  • member icon

Reputation: 4690
  • View blog
  • Posts: 17,385
  • Joined: 12-December 12

Re: how to list up and array the result from input file

Posted 15 August 2015 - 03:49 AM

How to use code tags:

Attached Image

What line(s) should we be looking at? It is obviously helpful if you can narrow down the problem for someone who might want to help you.

At a brief look, a major issue is that you don't have an array and you only print a single line:
Print #iOutputFile, EPOK, STN, DOY, NORTH, EAST, UP,

Read up on arrays. Learn how to define them and populate them. You need to do this and then attempt to use an array in your code.

This post has been edited by andrewsw: 15 August 2015 - 03:50 AM

Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • I'm not here to twist your niblets
  • member icon

Reputation: 4690
  • View blog
  • Posts: 17,385
  • Joined: 12-December 12

Re: how to list up and array the result from input file

Posted 15 August 2015 - 04:04 AM

Understanding Arrays
Was This Post Helpful? 0
  • +
  • -

#4 triplekkk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-August 15

Re: how to list up and array the result from input file

Posted 15 August 2015 - 06:24 AM

Hi Andrews....actually i need to read an entire information from the first line input until end of the line input and sort it......for your information The variable STN is refers to Station Name.....let say if the script found first station name BELU then it will list up all the information of that station sequentially according to the format i need and print it as BELU.txt....and the script will do the same procedure for other station name until the end of file .....

This is the output i need for your reference (BELU.TXT):

1 BELU 229 0.00096 0.00015 0.00514
2 BELU 230 -0.00009 -0.00134 -0.00084
3 BELU 231 -0.00211 0.00077 -0.00357

and so on until end of station name BELU.......The script then will print the same format for the other stations

thanks for your help....i'm appreciated if u could help me with this problems
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • I'm not here to twist your niblets
  • member icon

Reputation: 4690
  • View blog
  • Posts: 17,385
  • Joined: 12-December 12

Re: how to list up and array the result from input file

Posted 15 August 2015 - 06:30 AM

As I've said, you need to study the use of arrays and then attempt to use one within your code. We aren't going to teach you the subject of arrays. You need to study and make an attempt.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1