[futurebasic] Merge Files

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2006 : Group Archive : Group : All Groups

From: Brian Heibert <bheibert@...>
Date: Thu, 05 Jan 2006 18:06:10 -0500
Here is how my program opens files:
Down below this Is how my app saves files
How would I go about merging the current open file and a file the  
user selects?

Brian
/*
DIM fo1$
menu
DEF OPEN "HBSf"

dim wxn$,wt$
fo1$ = FILES$(_fOpen, "HBSf","Open HBasic file...",refNumVar%)
if fo1$ = "" then beep: FN fileError2:EXIT FN

wxn$ = "HBasic: "+fo1$+ " ( "+xnum+" )     "
WINDOW #_Editor, fo1$+" - HBasic"
wt$ = "HBasic ( "+xnum+" )"

OPEN "R",2,fo1$'I

'LINE INPUT #2, txt$
//PRINT #1, txt$
READ #2, txt$
EDIT FIELD _cEdit,txt$

*/
TEXT _Courier,13
DIM fileName$, refNumvar%, dataLine$
fileName$ = FILES$(_fopen, "HBSf", "Select a file:", refNumvar% )
IF fileName$ = "" THEN fn fileError2:EXIT FN
OPEN "I", 2, fileName$, ,refNumVar%
// clear previous contents of edit field
TEXT _Courier,13
EDIT$( _cEdit ) = ""
TEXT _Courier,13
// repeat loop while not End Of File
WHILE NOT EOF( 2 )
// get the next line of text (up to 'return')
LINE INPUT #2, dataLine$
// append it to end of info in edit field (with a 'return')
TEXT _Courier,13
EDIT$( _cEdit, _maxInt,_maxInt ) = dataLine$ + chr$(13)
WEND
CLOSE #2
// set cursor at end of edit field's info
SetSelect _maxInt, _maxInt
WINDOW _Editor, "HBasic - "+filename$


Save files:
menu
dim ed$
dim fo$,txt$
txt$ = EDIT$(_cEdit)
DIM fileName$, refNumVar%
DIM efHndl&, dataLine$, lineNum

//DEF OPEN "HBSfHBas"
fo$ = FILES$(_fSave,"Save HBasic file as...","New  
Program.HBSf",refNumVar%)
IF fo$ = "" then beep:FN fileError1:EXIT FN
DEF OPEN "HBSf"
OPEN "O", 1, fo$, ,refNumVar%
efHndl& = TEhandle( _cEdit )
FOR lineNum = 1 TO efHndl&..TEnLines%
dataLine$ = EDIT$( _cEdit, lineNum )
PRINT #1, dataLine$
NEXT lineNum
CLOSE #1
WINDOW _Editor, "HBasic - "+fo$


//PRINT #1, txt$
//CLOSE #1
menu