Qbasicnews.com

Full Version: DOn't poke and Don't peek!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
One more question.....
What is the use of those
peek and poke commandS???

and also if u cud explain about the usage of pallettes....

:roll:
I think you can PEEK all you want, but POKEing is dangerous, unless you really know what you're doing. I think PEEK reads the contents of a memory address, and POKE changes its contents.

PALETTE assigns colour attributes (red, green, blue) to numbers. This way you can build your very own palette, mixing those together.
POKEing isnt really dangerous, it can just funk up your program and at a stretch crash your computer.

Unless you consider that dangerous... :o

Anonymous

Yeah, it's not dangerous.. unless you consider permanently damaging your computer dangerous =)


Why do yu think modern OS's son't let you directly access hardware and stuff? You had too much power in DOS days.
Quote:Yeah, it's not dangerous.. unless you consider permanently damaging your computer dangerous =)


Why do yu think modern OS's son't let you directly access hardware and stuff? You had too much power in DOS days.

Hardware access is protected in order to implement resource sharing in a multitasking enviroment without forcing the programmer to understand how every other program out there operates. The actual physical damage you could possibly cause programatically is extremely limited. The only risks that come to mind are running a CRT at a refresh rate that burns up the monitor, and burning the servos in a disk drive by rapidly sweeping the read or write head from the inside track to the outside. Both task aren't exactly something you might do accidentally.
(Somewhat offtopic)

I've just realized POKE and PEEK, when used with VARPTR(), can be used as a substitute hack for pointers.

That's probably old news, but I just realized it and felt it had to be said.
well... i got that peek and poke
but where to use a pallette??
and what does it do?
and *How* to use it?
what is the use of it in a program?
can any one explain?
A palette is just a color lookup table. In display modes with 8 or less bits per pixel (all of the QB SCREEN modes, for instance) usually use a palette in order to have a wider range of colors than if they used a direct color scheme. When you write pixels on the screen in a mode with a palette, the number you use is not a direct representation of a color, but just an index into your palette (color table), which contains the real colors. This lets you do some nifty tricks, like rotating or fading the (relatively few) colors in the palette without changing the screen contents.