🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #5853

Re: problem manipulating binary data in postscript

#5853
From: Peter F Davis
Date: Tue, 29 Dec 1992 14:06
25 lines
1502 bytes
cahoon@femto.cs.umn.edu (Forrest Clinton Cahoon) writes:

>I'm trying to write some postscript which will color a hexagonal grid,
>reading the color data from the end of my ps file.  I'm reading one
>byte for each hexagon, then doing some bit-twiddling to get values to call
>setrgbcolor with before filling the hexagon.

>I've got a version using "read" which works, but since "read" treats my
>newline characters as valid binary data, it's not entirely
>satisfactory.

>What I want to use is "readhexstring", but since what this reads in is
>treated as a string rather than an integer, I'm having trouble.  I
>need to convert my one-byte string into an integer having the same
>binary representation.  I don't want "cvi", because this parses a
>string which represents an integer to us humans, and puts that value
>on the stack -- cvi would read (1) and put the integer value 1 on the
>stack, but what I need would take (1) and put the integer value 49 --
>the ASCII value of the character 1 -- on the stack.

Use 'get' to get any byte from the string as an integer:

	(A) 0 get

will put 65 on the stack.
Technical Details
Message-ID: <C00xu7.3qn@world.std.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!world!pd
References: <1992Dec28.171257.27785@news2.cis.umn.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript
Path: arc1-ca.pugleaf.net!sparky!uunet!world!pd
From: pd@world.std.com (Peter F Davis)
Subject: Re: problem manipulating binary data in postscript
Message-ID: <C00xu7.3qn@world.std.com>
Organization: The World Public Access UNIX, Brookline, MA
References: <1992Dec28.171257.27785@news2.cis.umn.edu>
Date: Tue, 29 Dec 1992 14:06:07 GMT
Lines: 25