PDA

View Full Version : Text Counter



trconnet
2008-03-20, 09:59 PM
I am trying to read lines out of each line of some files and place them in a new file.
I am trying to count the occurances of some text and place a counter.
I am getting a error of:
; error: bad function: "1"

Any hints are apprecriated,
Thanks,
TC



(DEFUN C:INDEXME (/ INDEXFILE KEYFILE HYDNUMSFILE FINALFILE INDEXO KEYO HYDNUMSO FINALO CT KEYR HYDNUMSR)
(SETQ INDEXFILE (GETFILED "WHAT IS INDEX FILE?" "/0/" "txt" 8))
(SETQ KEYFILE (GETFILED "WHAT IS KEY FILE?" "/0/" "txt" 8))
(SETQ HYDNUMSFILE (GETFILED "WHAT IS HYDRANT ID LIST?" "/0/" "txt" 8))
(SETQ FINALFILE (GETFILED "WHERE IS THE OUTPUT FILE?" "/0/" "txt" 8))

(SETQ INDEXO (OPEN INDEXFILE "R"))
(SETQ KEYO (OPEN KEYFILE "R"))
(SETQ HYDNUMSO (OPEN HYDNUMSFILE "R"))
(SETQ FINALO (OPEN FINALFILE "W"))

(SETQ CT 0)
(SETQ HYDNUMSR (READ-LINE HYDNUMSO))
(SETQ KEYR NIL)
(WHILE
(PROGN
(IF (/= KEYR HYDNUMSR)
(PROGN
(SETQ KEYR (READ-LINE KEYO))
(SETQ CT 0)
))
(WHILE
(= KEYR HYDNUMSR)
(SETQ CT (1+ CT))
(PRIN1 ((READ-LINE INDEXO) "\t") FINALO)
(PRIN1 HYDNUMSR FINALO)
(PRIN1 "\t" FINALO)
(PRIN1 CT FINALO)
(SETQ HYDNUMSR (READ-LINE HYDNUMSO))
)
)
)
(CLOSE FINALO)
(CLOSE INDEXO)
(CLOSE KEYO)
(CLOSE HYDNUMSO)
)

T.Willey
2008-03-20, 11:38 PM
Quick look.

This seems to be the problem.


(PRIN1 ((READ-LINE INDEXO) "\t") FINALO)


You need to use 'strcat' to combine the two text strings into one string.



(PRIN1 (strcat (READ-LINE INDEXO) "\t") FINALO)