Welcome! Please see the About page for a little more info on how this works.

0 votes
in Namespaces and vars by
closed by

So... to be quick, this is my core.clj file:

(ns ffmpeg-in-a-jar.core
  (:gen-class)
  (:require [ffmpeg-in-a-jar.encoder :as encoder]))

(defn -main
  "ffmpeg autoencoder made with Clojure"
  [& args]
  (println "Files will begin encoding..." ))

on encoder.clj file i've defined an user-defined loop counter:

(defn loop-cnt []
  (println "How many files to encode?")
  (def loopnum (read-string (read-line)))
  (println "\n""Files ready to encode"))

(loop-cnt)

it is right after used in a loop to again request the user for more input:

(defn queue []
  (loop [loopnum loopnum
         file-queue []]
   (if (not= loopnum 0)
     (do
       (def file-queue [])
       (println "\n""Write filenames one by one")
       (def add-queue (read-line))
       (recur (dec loopnum) (conj file-queue add-queue)))
     file-queue)))

im calling these with:

(loop-cnt)
(def queue-result (queue))
(println "\n""Added to the Encoding Queue:" "\n" queue-result "\n")

The real doubt im having is, how in the world is encoder even working, i use require to make it available but i've yet to call it inside -main with i guess should be:

(encoder/loop-cnt)
(println "\n" "Added to the Encoding Queue:" "\n" encoder/queue-result "\n")

is the ns macro doing something im unaware of?

closed with the note: Solved. Silly mistake

1 Answer

0 votes
by

just arrived home, recheked the code and seems like i was calling functions twice. Forgot to comment the in-file tests inside encoder.clj (which were running once by require then again by -main)

Oops :)

the new core.clj works as intended now

(ns ffmpeg_in_a_jar.core
  (:gen-class)
  (:require [ffmpeg_in_a_jar.encoder :as encoder]))

(defn -main
  "ffmpeg autoencoder made with Clojure"
  [& args]
  (encoder/loop-cnt)
  (def queue-result (encoder/queue))
  (println "\n" "Added to the Encoding Queue:" "\n" queue-result "\n")
  (println "Files will begin encoding..." ))
by
Just fyi, `def` creates global vars and should generally only be used at the top level - here you'd want `let` instead to create a local binding for queue-result, but same for your prior code with loop-num, file-queue, add-queue, etc.
...