Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Some simple questions

Author
Message
ChrisJ
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: United Kingdom
Posted: 3rd Nov 2002 14:33
I'm new to DBPro though I am an experienced C/C++ programmer and have done a lot of BASIC programming in
the past. First I have to say that DBPro seems very powerful but there also seem to be some curious omissions
e.g. error trapping (ON ERROR GOTO/GOSUB/xxxx) and a way to
get the mouse location at the time it is clicked rather than at the (arbitrary in relation to the click) time you
call mousex/y/z(). Also, the documentation needs a *lot* of improvement to do the product justice.

Anyhow, my question is much more prosaic. If I print some text to the screen as follows:

setcursor 200,200 : print "ABCDEF"

and then I want to erase *just* this text one might think
of doing

setcursor 200,200 : print space$(6)

but of course that doesn't work at all. It seems that printing spaces just moves the cursor and doesn't erase what was there before. Is there some simple way to achieve
what I want or do I have to re-draw the whole screen anew
each time (I really hope not).

Pointers appreciated.
Peter
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location:
Posted: 3rd Nov 2002 15:46
Maybe:
set cursor 200,200 : print " " ?

xtom
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 3rd Nov 2002 15:52
Text 200,200," " does work in this way but you have to set text to opaque. I don't know if it can be done with print.
rapscaLLion
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Canada
Posted: 3rd Nov 2002 16:12
I don't think it can be done... but why would you need to do that?

Alex Wanuch
aka rapscaLLion
Get the DB Weekly Newsletter at www.dbwn.cjb.net
ChrisJ
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: United Kingdom
Posted: 3rd Nov 2002 19:58
Thanks everyone. Seems like using the TEXT commands is much better than using the old fashioned PRINT stuff. The opaque text way works fine. As for *why* I'd need to erase some text from the screen (rapscaLLion) - I can think of several reasons without even trying.

Ratty Rat
22
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 4th Nov 2002 14:32
Hi, I`m not sure that printing spaces is the most efficient way of doing this (although it depends on exactly what you are doing). What if you use a proportional font, for instance, prining six spaces would not overwrite the entire six characters, try this instead:-



Incidentally DB/DBPro are not event driven languages (IE in Visual C++ when an 'event' occurs, such as a mouse click, it triggers a bit of code), rather they are 'Procedural' (IE there is a list of instructions, each instruction is executed in order) which is what most of the older coders (myself included) learnt to code in.
I remember it took me a while to get my head around event driven languages when I first encountered them, if this is the first procedural language you have used you will probably have to make a similar adjustment.
Richard Davey
Retired Moderator
23
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 5th Nov 2002 01:54
As Ratty has explained the fonts you use when you print to the screen are not fixed-width, so printing the right number of spaces as you had letters is meaningless because they're totally different widths. It's like the difference between the same word written in a Courier font as opposed to an Arial font.

Use the Text command as suggested for a lot more control, but more importantly you can get the exact height and width of your text in pixels, so if you need to you can draw a box (or blank out the area) over the top of it to the pixel.

Look at the "text width" and "text height" commands.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
DB Team / Atari ST / DarkForge / Retro Gaming
Ratty Rat
22
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 5th Nov 2002 14:49
Rich, you didn`t have time to look at my bit of code then?

)
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 5th Nov 2002 18:49
erm... erm... hmm...
well from what i understand he wants to overwrite the text he has just place yes?

but in what way do you wish to achieve this, by overwriting (insert style) or a backspace delete thing, or just complete replacement (updated value)?

lemme know which and i'll post the code, it'll be from the top of my head cause right now no DarkBasic access...

Anata aru kowagaru no watashi!

Login to post a reply

Server time is: 2025-08-08 17:12:09
Your offset time is: 2025-08-08 17:12:09