For Programmers: Free Programming Magazines  


Home > Archive > Clarion > September 2006 > Ascii File generation will not seperate









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Ascii File generation will not seperate
tcs@mvn.net

2006-09-22, 6:55 pm

I have a button that should generate multiple ACSII files. It produces
the first main page, but stores the additional pages in a single file.
The close,rename & remove in the bottom loop do not seem to be doing
as the should. What am I missing?

Thanks


!~~~~~~~~~~~~~~ Main Page Generator

OPEN(ASCFile)
IF ERRORCODE() = 2 ! File doesn't exist
CREATE(ASCFile)
OPEN(ASCFile)
END


picmax = Veh:page_lvl ! create picmax for subroutine
pixvar = veh:page_lvl - 1 ! how many rows
LinesVar = int(pixvar/3) ! How many Singles
modvar = pixvar%3

! create file name to store html code to
fpicname = 'c:\temp\' & Clip(veh:StockNo) & 'main.htm'


! end of common program (130 lines)


ACCESS:ASCFILE.CLOSE ! Close main program
rename('ascfile', fpicname) ! Rename file and place in C:\temp
remove(ascfile) ! Remove ascfile and prepare for next
routine

!~~~~~~~~~~~~~ End of Main Page generation
!~~~~~~~~~~~~~ Start of Sub-pages generation

loop PicVal = 2 to veh:page_lvl
remove(ascfile) ! Remove ascfile if/and
prepare for nextpage

OPEN(ASCFile)
IF ERRORCODE() = 2 ! File doesn't exist
CREATE(ASCFile)
OPEN(ASCFile)
END

! create filename to store html code to
fpicname = Clip(veh:StockNo) & '_' & format(picval,@n02) & '.htm'

! Subpage generation code (60 lines here)

ACCESS:ASCFILE.CLOSE ! Close subprg file
rename('ascfile', fpicname) ! Rename file
rename(fpicname, 'C:\temp') ! Rename file and place in
C:\temp


end ! loop

remove(ascfile) ! Remove ascfile and say good
night

!~~~~~~~~~~~~~~ End of Sub-pages

JonWat

2006-09-26, 6:55 pm

Not really a question of what you are missing, its more what are you
doing right (to be blunt).

You have a mix of opens and Access:file.closes(). You are using rename
(which calls the operating system) while you have files open. Really
not sure what that is going to do to your file handle.

You have a rename with a string as the first parameter, when it is
supposed to be a file handle. You have the second parameter of a rename
as a directory name rather than a file. You are removing some of the
files you have just written.

I suspect this is because you don't know how to associate ASCFILE (a
file handle) with an operating system file.

For each of the files you want to write, something like this should
work:

ascfile{PROP:Name} = 'somefilename'
OPEN(ASCFILE)
IF ERRORCODE() = 2 ! File doesn't exist
CREATE(ASCFile)
OPEN(ASCFile)
END
add records
CLOSE(ASCFILE)


tcs@mvn.net wrote:
> I have a button that should generate multiple ACSII files. It produces
> the first main page, but stores the additional pages in a single file.
> The close,rename & remove in the bottom loop do not seem to be doing
> as the should. What am I missing?
>
> Thanks
>
>
> !~~~~~~~~~~~~~~ Main Page Generator
>
> OPEN(ASCFile)
> IF ERRORCODE() = 2 ! File doesn't exist
> CREATE(ASCFile)
> OPEN(ASCFile)
> END
>
>
> picmax = Veh:page_lvl ! create picmax for subroutine
> pixvar = veh:page_lvl - 1 ! how many rows
> LinesVar = int(pixvar/3) ! How many Singles
> modvar = pixvar%3
>
> ! create file name to store html code to
> fpicname = 'c:\temp' & Clip(veh:StockNo) & 'main.htm'
>
>
> ! end of common program (130 lines)
>
>
> ACCESS:ASCFILE.CLOSE ! Close main program
> rename('ascfile', fpicname) ! Rename file and place in C:\temp
> remove(ascfile) ! Remove ascfile and prepare for next
> routine
>
> !~~~~~~~~~~~~~ End of Main Page generation
> !~~~~~~~~~~~~~ Start of Sub-pages generation
>
> loop PicVal = 2 to veh:page_lvl
> remove(ascfile) ! Remove ascfile if/and
> prepare for nextpage
>
> OPEN(ASCFile)
> IF ERRORCODE() = 2 ! File doesn't exist
> CREATE(ASCFile)
> OPEN(ASCFile)
> END
>
> ! create filename to store html code to
> fpicname = Clip(veh:StockNo) & '_' & format(picval,@n02) & '.htm'
>
> ! Subpage generation code (60 lines here)
>
> ACCESS:ASCFILE.CLOSE ! Close subprg file
> rename('ascfile', fpicname) ! Rename file
> rename(fpicname, 'C:\temp') ! Rename file and place in
> C:\temp
>
>
> end ! loop
>
> remove(ascfile) ! Remove ascfile and say good
> night
>
> !~~~~~~~~~~~~~~ End of Sub-pages


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com