delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/02/04:32:57

Message-ID: <D1FB30BBA491D1118E6D006097BCAE39105ACA@Probe-nt-2a.Probe.co.uk>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: I have a question for Allegro. I really hope someonce can ans
wer it!!!!
Date: Mon, 2 Mar 1998 09:32:48 -0000
MIME-Version: 1.0

Oren Marciano writes:
> What does this code actually do:
>
>  xgrid = MID(1, atoi(griddle_xgrid), 0xFFFF);
>
> xgrid is an int
> griddle_xgrid is a char

Not quite. Actually griddle_xgrid is an array of chars, ie. a string.

> what is MID, what is atoi, why is the last parimater 0xFFFF
>
> This is taken from the Allegro Grabber code.

atoi() is a standard C library function: see "info libc al atoi". It
converts an ASCII string into an integer, and in this case is being
used to read whatever value the user typed into the grid size edit box.

MID is a macro, defined in allegro.h, which clamps a value to a
particular range. In this case it is being used to make sure the grid
size will be something between 1 and 0xFFFF, to prevent any silly
values getting through and upsetting the grab function. There is no
particular reason for using 0xFFFF as the upper limit, other than that
it is suitably large and a nice round number.

	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019