home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Beter Homes & Gardens: Complete Guide to Gardening
/
GARDENS.BIN
/
gardens
/
pstdis
/
pstvarbl.bak
< prev
next >
Wrap
Text File
|
1994-04-01
|
4KB
|
201 lines
SET exclusive off
SET safety off
USE d:\grdncd\gardens\pstdis\pstdis.dbf EXCLUSIVE
* Alphabetize list
SET ORDER TO TAG name
* Housekeeping
goto top
index = 1
handle = 0
savsection = section
list = ""
* SET up file handle
filename = "d:\grdncd\gardens\" + SUBSTR(section,1,3) + "\pstdis\" + "pstdis.var"
IF FILE(filename)
ERASE filename
handle = FCREATE(filename) && If not create it
* handle = FOPEN(filename,12) && If so, open read/write
ELSE
handle = FCREATE(filename) && If not create it
ENDIF
* Done for each record
DO WHILE .NOT. EOF()
IF section <> savsection
* Output final list total
=FPUTS(handle,'@total')
=FPUTS(handle,ALLTRIM(STR(index-1)))
* Output list string
=FPUTS(handle,'@list')
=FPUTS(handle,SUBSTR(list,1,LEN(list)-1))
* Close previous file
=FCLOSE(handle)
* SET up file handle
filename = "d:\grdncd\gardens\" + SUBSTR(section,1,3) + "\pstdis\" + "pstdis.var"
IF FILE(filename)
ERASE filename
handle = FCREATE(filename) && If not create it
* handle = FOPEN(filename,12) && If so, open read/write
ELSE
handle = FCREATE(filename) && If not create it
ENDIF
index = 1
savsection = section
list = ""
ENDIF
* Output name
=FWRITE(handle,'@name[')
=FWRITE(handle,ALLTRIM(STR(index)))
=FPUTS(handle,']')
=FPUTS(handle,ALLTRIM(name))
* Output preview image name
=FWRITE(handle,'@image[')
=FWRITE(handle,ALLTRIM(STR(index)))
=FPUTS(handle,']')
* Get first image name
strptr = 1
DO WHILE strptr <= LEN(ALLTRIM(images))
IF SUBSTR(images,strptr,1) <> ";"
=FWRITE(handle,SUBSTR(images,strptr,1))
ELSE
EXIT
ENDIF
strptr = strptr + 1
ENDDO
=FPUTS(handle,'')
* Output directory
=FWRITE(handle,'@dir[')
=FWRITE(handle,ALLTRIM(STR(index)))
=FPUTS(handle,']')
=FPUTS(handle,ALLTRIM(dir))
list = list + ALLTRIM(name) + ";"
* Increment and get next record
index = index + 1 && increment list index
SKIP && get next record
enddo
* Output final list total
=FPUTS(handle,'@total')
=FPUTS(handle,ALLTRIM(STR(index-1)))
* Close file
=FCLOSE(handle)
* Rewind file to build species VAR files
SET ORDER TO TAG dir
GOTO TOP
savname = name
savimages = images
savdir = dir
savsect = section
aka = ""
* Done for each record
DO WHILE .NOT. EOF()
* Output VAR file at level break
IF dir <> savdir
DO write_var && write VAR file
* Garden Type specific data
savname = name
savimages = images
savdir = dir
savsect = section
ELSE && else of level break
* Build aka name
IF seq > "1"
aka = aka + ALLTRIM(name) + ";"
ENDIF
ENDIF
* Get next record
SKIP && get next record
ENDDO
DO write_var && handle last record
*
* PROCEDURE write_var - Writes the VAR file
*
PROCEDURE write_var
* set up file handle
filename = "d:\grdncd\gardens\" + SUBSTR(savsect,1,3) + "\pstdis\" + ALLTRIM(savdir) + "\"
filename = filename + ALLTRIM(savdir) + ".var"
IF FILE(filename) && if file exists, delete it
ERASE filename
handle = FCREATE(filename) && If not create it
ELSE
handle = FCREATE(filename) && If not create it
ENDIF
* Output name
=FPUTS(handle,'@name')
=FPUTS(handle,ALLTRIM(savname))
* Output aka name
=FPUTS(handle,'@aka')
IF LEN(aka) = 0
=FPUTS(handle,'None') && if no aka, put None
ELSE
=FPUTS(handle,substr(aka,1,len(aka)-1)) && if aka, lose last semicolon
ENDIF
aka = "" && init to null
* Output images
index = 1
=FWRITE(handle,'@image[')
=FWRITE(handle,ALLTRIM(STR(index)))
=FPUTS(handle,']')
* Get first image name
strptr = 1
DO WHILE strptr <= LEN(ALLTRIM(savimages))
IF SUBSTR(savimages,strptr,1) <> ";"
=FWRITE(handle,SUBSTR(savimages,strptr,1))
ELSE
index = index + 1
=FPUTS(handle,'') && force CR to new image
=FWRITE(handle,'@image[')
=FWRITE(handle,ALLTRIM(STR(index)))
=FPUTS(handle,']')
ENDIF
strptr = strptr + 1
ENDDO
=FPUTS(handle,'') && force last CR
* Output final image total
=FPUTS(handle,'@images')
=FPUTS(handle,ALLTRIM(STR(index)))
* Close file
=FCLOSE(handle)
RETURN