Author Topic: Get Current Fore and Back Color?  (Read 1628 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Get Current Fore and Back Color?
« on: September 06, 2018, 12:11:10 pm »
I want to get current color settings for screen before using COLOR in sub so that I can set the color back to what it was before the sub call.

Is there a way?

I am sure there are probably 10 but I don't know of an easy one except save the colors myself when I reset them.
The sub is meant to be reusable in anyone's program, like the list box for a selection from array.

Marked as best answer by bplus on September 06, 2018, 09:20:20 am

FellippeHeitor

  • Guest
Re: Get Current Fore and Back Color?
« Reply #1 on: September 06, 2018, 12:17:09 pm »
_DEFAULTCOLOR for fore color and _BACKGROUNDCOLOR for, you guessed it, back color.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Get Current Fore and Back Color?
« Reply #2 on: September 06, 2018, 12:21:39 pm »
Knowing Fellippe that 's likely the best answer, I calculate the bias at 99.9%

Thanks Fellippe!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Get Current Fore and Back Color?
« Reply #3 on: September 08, 2018, 01:47:00 pm »
In the old days, when you were still part egg, the way to do it was to print a hidden character, like chr$(0), in an unused place on the screen and then use the 1 switch in the SCREEN command to read the attribute of that character. Then you had to divide it by 16 and use mod 16 to find the foreground and background colors, and, of course, remove the hidden character.

Yeah, I know we're roughly the same age, but I couldn't resist cracking that egg joke, and since it was about being part egg, let's just leave it at the yolks on you.

Pete :D

- Dammit, I miss my smileys!
« Last Edit: September 08, 2018, 01:51:07 pm by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/