|
-
Jun 15th, 2006, 12:04 AM
#1
Thread Starter
Member
Merging 2 Sequential files
sorry an error in previous thread
Hello
Pl Help me with this simple solution
I want to merge two files How can i do it ?
VB Code:
OPEN "ADD.DAT" FOR INPUT AS#1
DO UNTIL EOF(1)
i% =i% + 1
if i% > ubound(Names$) then redim preserve Names$(1 to i%)
if i% > ubound(goals$) then redim preserve add$(1 to i%)
INPUT #1, Name$(i%), add$(i%)
LOOP
CLOSE #1
Which displays
"Ronaldo","Brazil"
"David","UK"
"Pele","Brazil"
"Mardona","Argentina"
"Doanald","SA"
"Schnider","Germany"
VB Code:
OPEN "Goals.Dat" FOR INPUT AS#1
DO UNTIL EOF(1)
s$=s%+1
if s% > ubound(Names$) then redim preserve Names$(1 to s%)
if s% > ubound(goals$) then redim preserve goals$(1 to s%)
INPUT #1, Names$(s%), goals$(s%)
LOOP
CLOSE #1
Which displays
"Ronaldo","10"
"David","4"
"Doanald","3"
"Schnider","2"
I want to merge above two files and get the result as
"Ronaldo","Brazil","10"
"David","UK","4"
"Pele","Brazil",""
"Mardona","Argentina",""
"Doanald","SA","3"
"Schnider","Germany","2"
Pl Help
Regards
Samyo
i
-
Jun 15th, 2006, 02:37 AM
#2
Addicted Member
Re: Merging 2 Sequential files
Hi Samyo
I hope this helps
Try this out
VB Code:
Open "Palyers.dat" for OutPut as #3
OPEN "ADD.DAT" FOR INPUT AS#1
While not eof(1)
c%=c%+1
INPUT #1, Name$(c%), add$(c%)
Wend
CLOSE #1
OPEN "Goals.Dat" FOR INPUT AS#2
While not eof(1)
s$=s%+1
INPUT #1, Names$(s%), goals$(s%)
Wend
CLOSE #1
For j% = 1 to c%
For k% = j% +1 to c%
if Names$(j%) > Names$(k%) then
tmp$ = Names$(k%)
Names$(k%) = Names$(j%)
Names$(j%) = tmp$
tmpadd$ = add$(k%)
add(K%) = add(j%)
add(j%) = Tmpadd$
end if
next k%
For m% = 1 to s%
For n% = m% +1 to s%
if Names$(m%) > Names$(n%) then
tmp$ = Names$(k%)
Names$(k%) = Names$(n%)
Names$(n%) = tmp$
tmpgoal$ = goal$(k%)
add(K%) = add(n%)
add(n%) = Tmpgoal$
end if
next m%
WRITE #3, Names#(j%), add$(j%) Goal$(j%)
Next j%
Close#3
Regds
Samf
-
Jun 29th, 2006, 12:39 PM
#3
Re: Merging 2 Sequential files
-
Jun 29th, 2006, 12:47 PM
#4
Lively Member
Re: Merging 2 Sequential files
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|