Yet again, I suspect I am having some trouble with Racket lists, rather 
than Pollen... but try as I might, I can't ferret out the difference 
between code I have running correctly in DrRacket and code I have running 
in Pollen. The goal here is to extract the current filename so that I can 
have PDF output to an appropriately named file--i.e. variable based on the 
filename of the source.

This model of the problem seems to work in DrRacket:

(define metas
  (hash "here-path" "/Users/csforste/temp/susan.txt"))

(string-replace (path->string (last (explode-path (string->path (hash-ref 
metas "here-path"))))) ".txt" ".pdf")

I'll grant, that's a little ugly--but the output is (as intended): 
*susan.txt*.

Here is some code from a PDF template modeled on the one in the Fourth 
Pollen Tutorial (and informed by some poking around on github (particularly 
Joel's).

◊(local-require racket/file racket/system racket/string)

; For filename
◊(define output-filename
   (string-replace (path->string
                    (last (explode-path (string->path (select-from-metas 
'here-path metas)))))
                   ".poly.pm"
                   ".pdf"))

For a file located at, /Users/csforste/Projects/openmods-pollen/test.poly.pm

produces the following error:

path->string: contract violation
>   expected: path?
>   given: '(last (#<path:/> #<path:Users> #<path:csforste> #<path:Projects> 
> #<path:openmods-pollen> #<path:test.poly.pm>))
>
>
here-path seems to be a string (rather than a path object), hence the 
string->path call. It seems as though *last *isn't evaluating... and so 
string->path is getting the whole list... but why?

Thanks,

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to