WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Boxes Functions
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Simple Drawing Program using Boxes Functions

Keywords: 	 boxes drawing boxes

Question:

With visions of sugarplums, I have turned my attention back to a script I was "playing" around with back before a barrage of projects came my way. I wanted to come up with my own simple drawing type program for the kids. The functionality of this program works fine, except that once the PenWidth and PenColor are set before I set the data tag, it cannot seem to be changed. I guess I must be missing something, and I hope someone can help. If I try and move around the tags - I fill up the command stack almost immediately. Anyway I can clean this up so it works right, or does someone have a better approach??? Thanks and Happy Holidays to everyone!
:DoEtch
Errormode(@cancel)
WHITE="255,255,255"
RED="255,0,0"
PURPLE="255,0,255"
CYAN="0,255,255"
DKBLUE="0,0,128"
BLUE="0,0,255"
LTGRAY="192,192,192"
GRAY="128,128,128"
GREEN="0,255,0"
YELLOW="255,255,0"
FAMILY=16
FONT="Bookman Old Style"
DKGRAY="64,64,64"
BLACK="0,0,0"
BoxCaption(1,"Press Button to Draw")
BoxesUp("0,0,1000,1000",@zoomed)
BoxDrawText(1,"300,100,700,200","Drawing Program",@FALSE,1)
BoxNew(2,"0,0,1000,1000",0)
PnWid=1
BoxButtonDraw(2,2,"E&xit", "800,850,900,900")
BoxButtonDraw(2,3,"Black Pen", "50,300,150,350")
BoxButtonDraw(2,4,"Blue Pen", "50,375,150,425")
BoxButtonDraw(2,5,"Green Pen", "50,450,150,500")
BoxButtonDraw(2,6,"Purple Pen", "50,525,150,575")
BoxButtonDraw(2,7,"Cyan Pen", "50,600,150,650")
BoxButtonDraw(2,8,"Yellow Pen", "50,675,150,725")
BoxButtonDraw(2,9,"Gray Pen", "50,750,150,800")
BoxButtonDraw(2,10,"Brush 1", "50,900,150,950")
BoxButtonDraw(2,11,"Brush 2", "175,900,275,950")
BoxButtonDraw(2,12,"Brush 3", "300,900,400,950")
BoxButtonDraw(2,13,"Brush 4", "425,900,525,950")
BoxButtonDraw(2,14,"Brush 5", "550,900,650,950")
olda="500,500"
exclusive(@ON)
while 1
BoxDataTag(2,"Tag1")
a=MouseInfo(6)
a=strreplace(a," ",",")
If MouseInfo(4) == 4 then BoxDrawLine(2,"%olda%,%a%")
BoxDataClear(2,"Tag1")
olda=a
if BoxButtonStat(2,2)== 1 then break
if BoxButtonStat(2,3)== 1 then BoxPen(2,BLACK,PnWid)
if BoxButtonStat(2,4)== 1 then BoxPen(2,BLUE,1)
if BoxButtonStat(2,5)== 1 then BoxPen(2,GREEN,PnWid)
if BoxButtonStat(2,6)== 1 then BoxPen(2,PURPLE,PnWid)
if BoxButtonStat(2,7)== 1 then BoxPen(2,CYAN,PnWid)
if BoxButtonStat(2,8)== 1 then BoxPen(2,YELLOW,PnWid)
if BoxButtonStat(2,9)== 1 then BoxPen(2,GRAY,PnWid)
if BoxButtonStat(2,10)== 1 then PnWid="1"
if BoxButtonStat(2,11)== 1 then PnWid="5"
if BoxButtonStat(2,12)== 1 then PnWid="10"
if BoxButtonStat(2,13)== 1 then PnWid="15"
if BoxButtonStat(2,14)== 1 then PnWid="25"
endwhile
BoxDestroy(2)
exclusive(@OFF)
Exit

Answer:

For starters, move the BoxDataTag outside the while loop. Leave the BoxDataClear alone. A little re-arranging...and WALLA!
:DoEtch
Errormode(@cancel)
WHITE="255,255,255"
RED="255,0,0"
PURPLE="255,0,255"
CYAN="0,255,255"
DKBLUE="0,0,128"
BLUE="0,0,255"
LTGRAY="192,192,192"
GRAY="128,128,128"
GREEN="0,255,0"
YELLOW="255,255,0"
FAMILY=16
FONT="Bookman Old Style"
DKGRAY="64,64,64"
BLACK="0,0,0"
BoxCaption(1,"Press Button to Draw")
BoxesUp("0,0,1000,1000",@zoomed)
BoxDrawText(1,"300,100,700,200","Drawing Program",@FALSE,1)
BoxNew(2,"0,0,1000,1000",0)
PnWid=1
PnClr=BLACK
BoxButtonDraw(2,2,"E&xit", "800,850,900,900")
BoxButtonDraw(2,3,"Black Pen", "50,300,150,350")
BoxButtonDraw(2,4,"Blue Pen", "50,375,150,425")
BoxButtonDraw(2,5,"Green Pen", "50,450,150,500")
BoxButtonDraw(2,6,"Purple Pen", "50,525,150,575")
BoxButtonDraw(2,7,"Cyan Pen", "50,600,150,650")
BoxButtonDraw(2,8,"Yellow Pen", "50,675,150,725")
BoxButtonDraw(2,9,"Gray Pen", "50,750,150,800")
BoxButtonDraw(2,10,"Brush 1", "50,900,150,950")
BoxButtonDraw(2,11,"Brush 2", "175,900,275,950")
BoxButtonDraw(2,12,"Brush 3", "300,900,400,950")
BoxButtonDraw(2,13,"Brush 4", "425,900,525,950")
BoxButtonDraw(2,14,"Brush 5", "550,900,650,950")
olda="500,500"
exclusive(@ON)
BoxDataTag(2,"Tag1")
while 1
        if BoxButtonStat(2,2)== 1 then break
        if BoxButtonStat(2,3)== 1 then pnClr=BLACK  ;BoxPen(2,BLACK,PnWid)
        if BoxButtonStat(2,4)== 1 then pnClr=BLUE   ;BoxPen(2,BLUE,1)
        if BoxButtonStat(2,5)== 1 then pnClr=GREEN  ;BoxPen(2,GREEN,PnWid)
        if BoxButtonStat(2,6)== 1 then pnClr=PURPLE ;BoxPen(2,PURPLE,PnWid)
        if BoxButtonStat(2,7)== 1 then pnClr=CYAN   ;BoxPen(2,CYAN,PnWid)
        if BoxButtonStat(2,8)== 1 then pnClr=YELLOW ;BoxPen(2,YELLOW,PnWid)
        if BoxButtonStat(2,9)== 1 then pnClr=GRAY   ;BoxPen(2,GRAY,PnWid)
        if BoxButtonStat(2,10)== 1 then PnWid="1"
        if BoxButtonStat(2,11)== 1 then PnWid="5"
        if BoxButtonStat(2,12)== 1 then PnWid="10"
        if BoxButtonStat(2,13)== 1 then PnWid="15"
        if BoxButtonStat(2,14)== 1 then PnWid="25"
        a=MouseInfo(6)
        a=strreplace(a," ",",")
        BoxPen(2,pnClr,PnWid)
        If MouseInfo(4) == 4 then BoxDrawLine(2,"%olda%,%a%")
        BoxDataClear(2,"Tag1")
        olda=a
endwhile
BoxDestroy(2)
exclusive(@OFF)
Exit

Article ID:   W12768
Filename:   Sample Drawing Program.txt
File Created: 1999:04:15:16:49:30
Last Updated: 1999:04:15:16:49:30