Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 29-09-2005, 03:49 PM   #1 (permalink)
In The Zone
 
Join Date: Jul 2005
Location: Hyderabad
Posts: 231
Default QBasic Multiple files appending


Well i have to edit multiple files situated in diffrent locations in the computer i know it can be done using the command [open "C:\file.txt" for append as #1] but my problem is that i have to append the same lines in the other files also so is there a way that i can append the same lines at a time to all the files [i am a lazy person i dont like to type much & any way i need my program to be small and fast] so is there a way to open multiple files and append all of the at once i tried doing thins but it didnt work

open "C:\file.txt" for append as #1
open "D:\file123.txt" for append as #1
Print #1, "hi Blha Blha BLHA"
close #1

but the compiler returned some error
__________________
fighting for peace is like ****ing for virginity
cryptid is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 29-09-2005, 05:25 PM   #2 (permalink)
Human Spambot
 
Join Date: Nov 2004
Location: Madurai
Posts: 2,349
Default

try putting the writing-to-file code within a subroutine, then use open .... for append as #1 and then gosub command...

The Below text is Pseudo code - I have forgotten 75% BASIC commands.

OPEN file1 for append as #1
gosub writeSub

OPEN file2 for append as #1
gosub writeSub

...

and then

writeSUB
{
Print #1, "xyz"
}


Arun
sakumar79 is offline  
Old 29-09-2005, 11:25 PM   #3 (permalink)
In The Zone
 
Join Date: Jul 2005
Location: Hyderabad
Posts: 231
Default

Quote:
Originally Posted by sakumar79
try putting the writing-to-file code within a subroutine, then use open .... for append as #1 and then gosub command...

The Below text is Pseudo code - I have forgotten 75% BASIC commands.

OPEN file1 for append as #1
gosub writeSub

OPEN file2 for append as #1
gosub writeSub

...

and then

writeSUB
{
Print #1, "xyz"
}


Arun
I tried doing this

OPEN "C:\WINDOWS\txt1.txt" FOR APPEND AS #1
GOSUB writeSub
OPEN "C:\Windows\txt2.txt" FOR APPEND AS #1
GOSUB writeSub
writeSub
{
PRINT #1, "Hi"
}

and the compiler gave a error sayin that "expected:statement" at the first Flower Bracket "{" what do i do now
__________________
fighting for peace is like ****ing for virginity
cryptid is offline  
Old 30-09-2005, 12:02 AM   #4 (permalink)
In The Zone
 
Join Date: Jul 2005
Location: Hyderabad
Posts: 231
Default

alright i got the solutoin to my previous problem now i got another problem after u open the first file and use the Gosub command it will write to the first file file and then it will skip the second file and continue with the codes after the writeSub what do i do to append to the seonf file also i tried using the goto command but then it will keep looping and flood the seconf file with "Hi" statement so please tell me what to do
__________________
fighting for peace is like ****ing for virginity
cryptid is offline  
Old 30-09-2005, 06:30 AM   #5 (permalink)
Human Spambot
 
Join Date: Nov 2004
Location: Madurai
Posts: 2,349
Default

forgot to close the file havent we? can be a part of the gosub (at the end) or of the main program (before the open file command for the second file)

Arun
sakumar79 is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Who
- by bhaskar
- by soumya
- by clinton
- by Sujeet

Advertisement




All times are GMT +5.5. The time now is 11:35 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2