help-circle
rss

[Common Lisp] How do I read a 32-bit integer from a binary (file) stream?
I can't figure out how to read multiple bytes. I'm trying to read a 32-bit integer so that I can store it to be used by a class. My (truncated) code: ``` (let ((version-buffer (byte 4 0))) (read-sequence version-buffer input-stream) (cond ((> version-buffer 10) (read-sequence minor-version-buffer input-stream)) (t t)) (setf (navigation-mesh-version temp-mesh) `(,(version-buffer)) ) ) ``` EDIT: Truncated the code further.
fedilink

How do I insert control characters into a string with hex?
I'm trying to read a string and verify it's magic number (0xFEEDFACE); but I don't know how to insert an ascii character (as a number) into strings. Here is my code: ``` ;; Parser library for the Source Engine Nav mesh format. (defun parse-nav-string (input-string) "Parses string as Nav file." ;; Test for magic string 0xFEEDFACE. (cond (string= (subseq input-string 0 3) (concatenate (code-char #xCE) (code-char #xFA) (code-char #xED) (code-char #xFE)) ) (t (format *error-output* "Magic string not found!") ) ) () ) ```
fedilink


Ask specific questions about how to code something in lisp, scheme, racket, etc

Common-Lisp Resources

General lisp discussion on lemmy.ml

Create Post From:
lemmy.ml

  • 0 users online
  • 1 user / day
  • 1 user / week
  • 1 user / month
  • 3 users / 6 months
  • 6 subscribers
  • 4 Posts
  • 3 Comments
  • Modlog
Heap Overflow
A place to ask programming questions and share free resources

General programming discussion,
Additional resources, challenges

To post or comment:

  1. Create an account on another lemmy instance
  2. Then search for the community url like here

RULES:

  1. No politics
  2. No flaming / trolling
  3. No proprietary BS
  4. Stay on topic

Please keep questions & examples short!

All content is Public Domain unless otherwise specified.
Only CC0, CC BY 3.0, or CC BY-SA 3.0 alternate licenses are allowed.

No affiliation with StackOverflow.com