Page 1 of 1

Posted: Sat Mar 22, 2003 8:33 pm
by BackupUser
Restored from previous forum. Originally posted by LJ.

I have an application that as a user clicks on forward and backward buttons, a screen of text changes. The text is being read from data statements, RESTORING to the appropriate screen number.

While monitoring the .exe size in Task Manager, I noticed that each time the user clicks on a forward or backward button, the .exe increases in memory by about 8K.

Has anyone else programmed a similar application and had to deal with memory leaking? I believe that it's something I'm doing in my drawscreen procedure that's increasing the amount of memory being used each time the screen is redrawn.

Posted: Sat Mar 22, 2003 8:50 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Sorry, but without any code, I can't help you.
There are much things that can cause that.

Please post some example, so we can see, what is going on.

Timo

Posted: Sat Mar 22, 2003 9:02 pm
by BackupUser
Restored from previous forum. Originally posted by LJ.

Sure thing Timo.

There are a few images that can't be shown in the code below. Also, don't worry about the fonts loaded that are the same in the beginning, I'm just testing and brainstorming using different fonts in the future, that is all. I think the code that is leaking is somewhere in the main DrawScreen procedure.

On the first screen select Click Here. When the next screen is displayed, click on the "One" button under the heading "Lesson".

Next, click on the empty buttons at the bottom left corner of the screen to go forward and backward.

Open up Task Manager and watch the size of the .exe in memory increase just a little bit each time you click on the forward and backward buttons. If you click on them enough, the .exe in memory will get very large.


LoadFont (1, "Arial", 10)
LoadFont (2, "Arial", 10)
LoadFont (3, "Arial", 10)

LoadImage(0,"test.bmp")
LoadImage(1,"test1.bmp")
LoadImage(2,"test2.bmp")


Global lessons
Global ques
Global Steps
Global currentlesson
Global currentstep
Global area
Global lessontxt$
Global talklines
Global riwr$
Global screen
Global quesflag,dewey
Global door1$,door2$,door3$,one$,two$,three$,gamess$,staydoor,nostaydoor,gawin,ngawin,secondd,thirdd,fourd,fived,sixd,sevend
Global bbut$,fbut$

Dim talk.s(17)
Dim prof.s(10)

Procedure ReadQuestion()
For k = 1 To 18
Read tmp.s
talk(k)=tmp
Next k
EndProcedure

Procedure ReadDataStatements()
For k = 1 To 17
Read tmp.s
talk(k)=tmp
Next k
talklines = 0
For k = 1 To 10
Read tmp.s
prof(k)=tmp
talklines = talklines + 1
If prof(k) = ""
talklines = talklines - 1
EndIf
Next k
EndProcedure

Procedure DrawScreen()

#Image = 3
#ImageGadget = 4
CreateImage(#Image, 800,600)
UseImage(#Image)
StartDrawing(ImageOutput())
FrontColor(212, 208, 200)
Box(0, 0, 100, 600)
DrawingMode(1)
DrawingFont(UseFont(1))
Locate(1, 5)
FrontColor(0, 0, 0)
DrawText("Lesson")
Locate(15, 220)
DrawText("Step")

;Draw Professor Text Routines
FrontColor(34, 85, 136)
Box(100, 0, 700, 600)
If ques = 0
DrawImage(UseImage(0),680,390); Draw Professor
FreeGadget (15):FreeGadget(16):FreeGadget(17):FreeGadget(18)
If talklines = 1

FrontColor(255,255,225)
Box(280,405,430,40)
FrontColor(0,0,0)
Locate(290,405)
DrawText(prof(1))
EndIf

If talklines = 2

FrontColor(255,255,225)
Box(280,385,430,60)
FrontColor(0,0,0)
Locate(290,385)
DrawText(prof(1))
Locate(290,405)
DrawText(prof(2))
EndIf

If talklines = 3

FrontColor(255,255,225)
Box(280,365,430,80)
FrontColor(0,0,0)
Locate(290,365)
DrawText(prof(1))
Locate(290,385)
DrawText(prof(2))
Locate(290,405)
DrawText(prof(3))
EndIf

If talklines = 4

FrontColor(255,255,225)
Box(280,345,430,100)
FrontColor(0,0,0)
Locate(290,345)
DrawText(prof(1))
Locate(290,365)
DrawText(prof(2))
Locate(290,385)
DrawText(prof(3))
Locate(290,405)
DrawText(prof(4))
EndIf

If talklines = 5

FrontColor(255,255,225)
Box(280,325,430,120)
FrontColor(0,0,0)
Locate(290,325)
DrawText(prof(1))
Locate(290,345)
DrawText(prof(2))
Locate(290,365)
DrawText(prof(3))
Locate(290,385)
DrawText(prof(4))
Locate(290,405)
DrawText(prof(5))
EndIf

If talklines = 6

FrontColor(255,255,225)
Box(280,305,430,140)
FrontColor(0,0,0)
Locate(290,305)
DrawText(prof(1))
Locate(290,325)
DrawText(prof(2))
Locate(290,345)
DrawText(prof(3))
Locate(290,365)
DrawText(prof(4))
Locate(290,385)
DrawText(prof(5))
Locate(290,405)
DrawText(prof(6))
EndIf

If talklines = 7

FrontColor(255,255,225)
Box(280,285,430,160)
FrontColor(0,0,0)
Locate(290,285)
DrawText(prof(1))
Locate(290,305)
DrawText(prof(2))
Locate(290,325)
DrawText(prof(3))
Locate(290,345)
DrawText(prof(4))
Locate(290,365)
DrawText(prof(5))
Locate(290,385)
DrawText(prof(6))
Locate(290,405)
DrawText(prof(7))
EndIf

If talklines = 8

FrontColor(255,255,225)
Box(280,265,430,180)
FrontColor(0,0,0)
Locate(290,265)
DrawText(prof(1))
Locate(290,285)
DrawText(prof(2))
Locate(290,305)
DrawText(prof(3))
Locate(290,325)
DrawText(prof(4))
Locate(290,345)
DrawText(prof(5))
Locate(290,365)
DrawText(prof(6))
Locate(290,385)
DrawText(prof(7))
Locate(290,405)
DrawText(prof(8))
EndIf

If talklines = 9

FrontColor(255,255,225)
Box(280,245,430,200)
FrontColor(0,0,0)
Locate(290,245)
DrawText(prof(1))
Locate(290,265)
DrawText(prof(2))
Locate(290,285)
DrawText(prof(3))
Locate(290,305)
DrawText(prof(4))
Locate(290,325)
DrawText(prof(5))
Locate(290,345)
DrawText(prof(6))
Locate(290,365)
DrawText(prof(7))
Locate(290,385)
DrawText(prof(8))
Locate(290,405)
DrawText(prof(9))
EndIf

If talklines = 10

FrontColor(255,255,225)
Box(280,225,430,220)
FrontColor(0,0,0)
Locate(290,225)
DrawText(prof(1))
Locate(290,245)
DrawText(prof(2))
Locate(290,265)
DrawText(prof(3))
Locate(290,285)
DrawText(prof(4))
Locate(290,305)
DrawText(prof(5))
Locate(290,325)
DrawText(prof(6))
Locate(290,345)
DrawText(prof(7))
Locate(290,365)
DrawText(prof(8))
Locate(290,385)
DrawText(prof(9))
Locate(290,405)
DrawText(prof(10))
EndIf
EndIf


DrawingFont(UseFont(3))
DrawText(talk(17))

StopDrawing()
ImageGadget(#ImageGadget, 0, 0, 200, 600, UseImage(#Image))
CreateGadgetList(WindowID())
ButtonGadget(6, 10, 255, 75, 30, "One")
ButtonGadget(7, 10, 290, 75, 30, "Two")
ButtonGadget(8, 10, 325, 75, 30, "Three")
ButtonGadget(9, 10, 360, 75, 30, "Four")
ButtonGadget(10, 10, 395, 75, 30, "Five")
ButtonGadget(11, 10, 430, 75, 30, "Six")
ButtonImageGadget(12,10,480,32,30,UseImage(1))
ButtonImageGadget(13,53,480,32,30,UseImage(2))

;Create Buttons A, B, C, or D next to Sentence
If ques = 1
If Len(talk(1)) > 2
If Left(talk(1),2)="A."
ButtonGadget(15, 152,2, 30, 20, "A")
EndIf
If Left(talk(1),2)="B."
ButtonGadget(16, 152,2, 30, 20, "B")
EndIf
If Left(talk(1),2)="C."
ButtonGadget(17, 152,2, 30, 20, "C")
EndIf
If Left(talk(1),2)="D."
ButtonGadget(18, 152,2, 30, 20, "D")
EndIf
EndIf

If Len(talk(2)) > 2
If Left(talk(2),2)="A."
ButtonGadget(15, 152,22, 30, 20, "A")
EndIf
If Left(talk(2),2)="B."
ButtonGadget(16, 152,22, 30, 20, "B")
EndIf
If Left(talk(2),2)="C."
ButtonGadget(17, 152,22, 30, 20, "C")
EndIf
If Left(talk(2),2)="D."
ButtonGadget(18, 152,22, 30, 20, "D")
EndIf
EndIf

If Len(talk(3)) > 2
If Left(talk(3),2)="A."
ButtonGadget(15, 152,42, 30, 20, "A")
EndIf
If Left(talk(3),2)="B."
ButtonGadget(16, 152,42, 30, 20, "B")
EndIf
If Left(talk(3),2)="C."
ButtonGadget(17, 152,42, 30, 20, "C")
EndIf
If Left(talk(3),2)="D."
ButtonGadget(18, 152,42, 30, 20, "D")
EndIf
EndIf

If Len(talk(4)) > 2
If Left(talk(4),2)="A."
ButtonGadget(15, 152,62, 30, 20, "A")
EndIf
If Left(talk(4),2)="B."
ButtonGadget(16, 152,62, 30, 20, "B")
EndIf
If Left(talk(4),2)="C."
ButtonGadget(17, 152,62, 30, 20, "C")
EndIf
If Left(talk(4),2)="D."
ButtonGadget(18, 152,62, 30, 20, "D")
EndIf
EndIf

If Len(talk(5)) > 2
If Left(talk(5),2)="A."
ButtonGadget(15, 152,82, 30, 20, "A")
EndIf
If Left(talk(5),2)="B."
ButtonGadget(16, 152,82, 30, 20, "B")
EndIf
If Left(talk(5),2)="C."
ButtonGadget(17, 152,82, 30, 20, "C")
EndIf
If Left(talk(5),2)="D."
ButtonGadget(18, 152,82, 30, 20, "D")
EndIf
EndIf

If Len(talk(6)) > 2
If Left(talk(6),2)="A."
ButtonGadget(15, 152,102, 30, 20, "A")
EndIf
If Left(talk(6),2)="B."
ButtonGadget(16, 152,102, 30, 20, "B")
EndIf
If Left(talk(6),2)="C."
ButtonGadget(17, 152,102, 30, 20, "C")
EndIf
If Left(talk(6),2)="D."
ButtonGadget(18, 152,102, 30, 20, "D")
EndIf
EndIf

If Len(talk(7)) > 2
If Left(talk(7),2)="A."
ButtonGadget(15, 152,122, 30, 20, "A")
EndIf
If Left(talk(7),2)="B."
ButtonGadget(16, 152,122, 30, 20, "B")
EndIf
If Left(talk(7),2)="C."
ButtonGadget(17, 152,122, 30, 20, "C")
EndIf
If Left(talk(7),2)="D."
ButtonGadget(18, 152,122, 30, 20, "D")
EndIf
EndIf

If Len(talk(8)) > 2
If Left(talk(8),2)="A."
ButtonGadget(15, 152,142, 30, 20, "A")
EndIf
If Left(talk(8),2)="B."
ButtonGadget(16, 152,142, 30, 20, "B")
EndIf
If Left(talk(8),2)="C."
ButtonGadget(17, 152,142, 30, 20, "C")
EndIf
If Left(talk(8),2)="D."
ButtonGadget(18, 152,142, 30, 20, "D")
EndIf
EndIf

If Len(talk(9)) > 2
If Left(talk(9),2)="A."
ButtonGadget(15, 152,162, 30, 20, "A")
EndIf
If Left(talk(9),2)="B."
ButtonGadget(16, 152,162, 30, 20, "B")
EndIf
If Left(talk(9),2)="C."
ButtonGadget(17, 152,162, 30, 20, "C")
EndIf
If Left(talk(9),2)="D."
ButtonGadget(18, 152,162, 30, 20, "D")
EndIf
EndIf

If Len(talk(10)) > 2
If Left(talk(10),2)="A."
ButtonGadget(15, 152,182, 30, 20, "A")
EndIf
If Left(talk(10),2)="B."
ButtonGadget(16, 152,182, 30, 20, "B")
EndIf
If Left(talk(10),2)="C."
ButtonGadget(17, 152,182, 30, 20, "C")
EndIf
If Left(talk(10),2)="D."
ButtonGadget(18, 152,182, 30, 20, "D")
EndIf
EndIf

If Len(talk(11)) > 2
If Left(talk(11),2)="A."
ButtonGadget(15, 152,202, 30, 20, "A")
EndIf
If Left(talk(11),2)="B."
ButtonGadget(16, 152,202, 30, 20, "B")
EndIf
If Left(talk(11),2)="C."
ButtonGadget(17, 152,202, 30, 20, "C")
EndIf
If Left(talk(11),2)="D."
ButtonGadget(18, 152,202, 30, 20, "D")
EndIf
EndIf

If Len(talk(12)) > 2
If Left(talk(12),2)="A."
ButtonGadget(15, 152,222, 30, 20, "A")
EndIf
If Left(talk(12),2)="B."
ButtonGadget(16, 152,222, 30, 20, "B")
EndIf
If Left(talk(12),2)="C."
ButtonGadget(17, 152,222, 30, 20, "C")
EndIf
If Left(talk(12),2)="D."
ButtonGadget(18, 152,222, 30, 20, "D")
EndIf
EndIf

If Len(talk(13)) > 2
If Left(talk(13),2)="A."
ButtonGadget(15, 152,242, 30, 20, "A")
EndIf
If Left(talk(13),2)="B."
ButtonGadget(16, 152,242, 30, 20, "B")
EndIf
If Left(talk(13),2)="C."
ButtonGadget(17, 152,242, 30, 20, "C")
EndIf
If Left(talk(13),2)="D."
ButtonGadget(18, 152,242, 30, 20, "D")
EndIf
EndIf

If Len(talk(14)) > 2
If Left(talk(14),2)="A."
ButtonGadget(15, 152,262, 30, 20, "A")
EndIf
If Left(talk(14),2)="B."
ButtonGadget(16, 152,262, 30, 20, "B")
EndIf
If Left(talk(14),2)="C."
ButtonGadget(17, 152,262, 30, 20, "C")
EndIf
If Left(talk(14),2)="D."
ButtonGadget(18, 152,262, 30, 20, "D")
EndIf
EndIf

If Len(talk(15)) > 2
If Left(talk(15),2)="A."
ButtonGadget(15, 152,282, 30, 20, "A")
EndIf
If Left(talk(15),2)="B."
ButtonGadget(16, 152,282, 30, 20, "B")
EndIf
If Left(talk(15),2)="C."
ButtonGadget(17, 152,282, 30, 20, "C")
EndIf
If Left(talk(15),2)="D."
ButtonGadget(18, 152,282, 30, 20, "D")
EndIf
EndIf

If Len(talk(16)) > 2
If Left(talk(16),2)="A."
ButtonGadget(15, 152,302, 30, 20, "A")
EndIf
If Left(talk(16),2)="B."
ButtonGadget(16, 152,302, 30, 20, "B")
EndIf
If Left(talk(16),2)="C."
ButtonGadget(17, 152,302, 30, 20, "C")
EndIf
If Left(talk(16),2)="D."
ButtonGadget(18, 152,302, 30, 20, "D")
EndIf
EndIf

If Len(talk(17)) > 2
If Left(talk(17),2)="A."
ButtonGadget(15, 152,322, 30, 20, "A")
EndIf
If Left(talk(17),2)="B."
ButtonGadget(16, 152,322, 30, 20, "B")
EndIf
If Left(talk(17),2)="C."
ButtonGadget(17, 152,322, 30, 20, "C")
EndIf
If Left(talk(17),2)="D."
ButtonGadget(18, 152,322, 30, 20, "D")
EndIf
EndIf
EndIf

ClosePanelGadget()

CreateGadgetList(WindowID())
ButtonGadget(1, 10, 40, 75, 30, "One")
If lessons > 1
ButtonGadget(2, 10, 75, 75, 30, "Two")
EndIf
If lessons > 2
ButtonGadget(3, 10, 110, 75, 30, "Three")
EndIf
If lessons > 3
ButtonGadget(4, 10, 145, 75, 30, "Four")
EndIf
If lessons > 4
ButtonGadget(5, 10, 180, 75, 30, "Five")
EndIf
ClosePanelGadget()

If steps = 0
HideGadget(6, 1):HideGadget(7, 1):HideGadget(8, 1):HideGadget(9, 1)
HideGadget(10, 1):HideGadget(11, 1)
EndIf

If steps = 1
HideGadget(7, 1):HideGadget(8, 1):HideGadget(9, 1):HideGadget(10, 1)
HideGadget(11, 1)
EndIf

If steps = 2
HideGadget(8, 1):HideGadget(9, 1):HideGadget(10, 1):HideGadget(11, 1)
EndIf

If steps = 3
HideGadget(9, 1):HideGadget(10, 1):HideGadget(11, 1)
EndIf

If steps = 4
HideGadget(10, 1):HideGadget(11, 1)
EndIf

If steps = 5
HideGadget(11, 1)
EndIf
riwr$=""
EndProcedure

dewey = 0

hWnd = OpenWindow(0, 0, 0, 796, 560, #PB_Window_SystemMenu, "Main Window")
CreateMenu(0, WindowID())
MenuTitle("Project")
MenuItem(0, "New")
MenuItem(1, "Open")
MenuItem(2, "Save")

SetWinBackgroundColor(hWnd, RGB( 34, 85, 136))

CreateGadgetList(WindowID())
ButtonGadget(1, 315, 160, 102, 29, "Click Here")
ButtonGadget(2, 315, 200, 102, 29, "blank")
ClosePanelGadget()
;LoadImage(0,"test.bmp")
;StartDrawing(WindowOutput())
;DrawImage(UseImage(0), 0, 0)
;StopDrawing()
;ImageGadget(3, 100,10,150,150,UseImage(0))
;ClosePanelGadget()

Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 1 ; Quit...
FreeGadget (1)
FreeGadget (2)
area = 1
Goto lesson1screen

Case 2 ;
FreeGadget (1)
FreeGadget (2)
area = 2
Goto lesson1screen
EndSelect

EndIf

Until EventID = #PB_EventCloseWindow
End

lesson1screen:

If area = 1
lessons = 5
EndIf

If area = 2
lessons = 3
EndIf


currentlesson = 1
steps = 0
talklines=1
prof(1) = "Sample text"

DrawScreen()
DisableGadget(12,1):DisableGadget(13,1)

Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 1 ; Quit...
If area = 1
steps = 3
screen = 1
Gosub DataTable
DrawScreen()
EndIf

;Case 2 ;
; FreeGadget (1)
; FreeGadget (2)

;Goto 1screen
Case 12
screen = screen - 1
If screen < 1
screen = 1
Else
Gosub DataTable
DrawScreen()
EndIf

Case 13
screen = screen + 1
Gosub DataTable
DrawScreen()

Case 15
If talk(18) = "a"
riwr$="Correct"
screen = screen + 1
Gosub DataTable
DrawScreen()
Else
riwr$="Wrong"
screen = screen + 1
Gosub DataTable
DrawScreen()
EndIf

Case 16
If talk(18) = "b"
riwr$="Correct"
screen = screen + 1
Gosub DataTable
DrawScreen()
Else
riwr$="Wrong"
screen = screen + 1
Gosub DataTable
DrawScreen()
EndIf

Case 17
If talk(18) = "c"
riwr$="Correct"
screen = screen + 1
Gosub DataTable
DrawScreen()
Else
riwr$="Wrong"
screen = screen + 1
Gosub DataTable
DrawScreen()
EndIf

Case 18
If talk(18) = "d"
riwr$="Correct"
screen = screen + 1
Gosub DataTable
DrawScreen()
Else
riwr$="Wrong"
screen = screen + 1
Gosub DataTable
DrawScreen()
EndIf

EndSelect
EndIf

Until EventID = #PB_EventCloseWindow
End

DataTable:
ques=0

If screen = 1
Restore screen1
ReadDataStatements()
EndIf

If screen = 2
Restore screen2
ReadDataStatements()
EndIf

If screen = 3
Restore screen3
ReadDataStatements()
EndIf

If screen = 4
Restore screen4
ReadDataStatements()
EndIf

If screen = 5
Restore screen5
ques=1
ReadQuestion()
EndIf

If screen = 6
Restore screen6
ReadDataStatements()
EndIf


Return


DataSection
screen1:
Data.s "Lesson 1 - Permutations"
Data.s ""
Data.s "The factorial symbol ! denotes the product of decreasing positive whole"
Data.s "numbers. For example: 4! = 4 x 3 x 2 x 1 = 24 (Most calculators have a"
Data.s "factorial key.) A collection of n different items can be arranged in"
Data.s "order n! different ways. (This factorial rule reflects the fact that the"
Data.s "first item may be selected n different ways, the second item may be"
Data.s "selected n - 1 ways, and so on.)"
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""

Data.s "Grab your calculator. Make sure it is the same calculator you"
Data.s "will be using at your testing site. Some calculators are"
Data.s "designed to automatically calculate permutations such as the"
Data.s "TI-83. I will not be using this type of calculator because not"
Data.s "everyone can afford one. If your calculator lacks such a"
Data.s "feature, no worries, it is still easy to calculate n! by using the"
Data.s "factorial key identified as !"
Data.s ""
Data.s ""
Data.s ""

screen2:
Data.s "EXAMPLE Federal Express wants to find the shortest routes for"
Data.s "its deliveries. The delivery areas are in 3 cities denoted by"
Data.s "A, B, C. How many routes are possible?"
Data.s ""
Data.s "SOLUTION Using the factorial rule, we see that the 3 different"
Data.s "cities (A, B, C) can be arranged in 3! = 3 x 2 x 1 = 6 different"
Data.s "ways."
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""

Data.s "The reason the sign ! is used for factoring is that the answers"
Data.s "can get very long. For example lets say you have been hired by"
Data.s "New York School District to conduct a survey in each of the 50"
Data.s "state capitals. As you plan your travels, you want to determine"
Data.s "the number of different possible routes. How many different"
Data.s "routes are possible? By applying the factorial rule, we know"
Data.s "that 50 state capitals can be arranged 50! ways. So the number"
Data.s "of different routes is 50!, or 30,414,093,201,713,378,043,612,"
Data.s "608,166,064,768,844,377,641,568,960,512,000,000,000,000."
Data.s "This answer is large and so instead we use the symbol !, as in 50!"

screen3:
Data.s "Sometimes the number of n items are all different. The rule of"
Data.s "permutations states that we solve this by n!/(n-r)!"
Data.s "EXAMPLE In planning the Monday-night prime-time lineup for the"
Data.s "NBC television network, an executive must select 6 shows from 30"
Data.s "that are available. How many different lineups are possible?"
Data.s ""
Data.s "SOLUTION We need to select r = 6 shows from n = 30 shows"
Data.s "available. Order is relevant because the viewing audience changes"
Data.s "later in the evening. Because order counts, we use:"
Data.s "30! / (30-6)! = 427,518,000 possible lineups."
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""

Data.s "On your calculator type 30, then push the x! key. You should see"
Data.s "the number 2.6525285981e32 appear. Now press the divide key,"
Data.s "and type 24 and push the x! key. You should see the number"
Data.s "6.2044840173e23 appear. Now press the = key and the answer"
Data.s "427,518,000 will appear."
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""

screen4:
Data.s "We sometimes need to find the number of permutations, but some"
Data.s "of the items are identical to others. The following variation of the"
Data.s "permutations rule applies to such cases:"
Data.s "n! / n1!n2!...nk!"
Data.s "EXAMPLE How many different ways can the letters AAAABBBBB"
Data.s "be arranged?"
Data.s "SOLUTION In the sequence AAAABBBBB we have n = 9 items, with"
Data.s "n1 = 4 alike and n2 = 5 others that are alike. The number of"
Data.s "permutations is computed as follows: 9! / 4! 5! = 126 different"
Data.s "possible sequences of AAAABBBBB."
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""

Data.s "On your calculator type 9, then push the x! key. You should see"
Data.s "the number 362,880 appear. Write this number on your scratch"
Data.s "paper. Clear the calculator and type 4, then push the x! key."
Data.s "The number 24 will appear. Now press the multiply key and type"
Data.s "5, then push the x! key. The number 120 will appear. Now push"
Data.s "the = key and the number 2880 will appear. Write this number"
Data.s "down and clear the calculator. Now type into the calculator"
Data.s "the first number you wrote down, 362,880 and press the divide"
Data.s "key and type in the second number you wrote down, 2,880 and"
Data.s "press the = key. The answer 126 will appear."

screen5:
Data.s "If Gallup plans to conduct a consumer survey by asking subjects 5"
Data.s "questions, how many different versions of the survey are required"
Data.s "if all possible arrangements are included?"
Data.s ""
Data.s "Which rule below is used to solve this problem?"
Data.s ""
Data.s "A. Factorial Rule [n!]"
Data.s "B. Permutations Rule [n! / (n-r)!]"
Data.s "C. Permutations Rule [n! / n1!n2!...nk!]"
Data.s "D. Permu-Factorial Rule [combined]"
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s "a"

screen6:
Data.s ""
Data.s ""
Data.s "A. Factorial Rule [n!] "
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""

Data.s "Remember, the Factorial Rule tells us how many arrangements"
Data.s "are possible when ALL of n different items are used."
Data.s "The Permutations Rule, choice B, is used when we want"
Data.s "to select only SOME of the n items. The other Permutations"
Data.s "Rule choice C, is used when some items are identical to others."
Data.s "There is no such thing as choice D."
Data.s ""
Data.s ""
Data.s ""
Data.s ""
EndDataSection

Posted: Sat Mar 22, 2003 10:03 pm
by BackupUser
Restored from previous forum. Originally posted by LJ.

I'm sort of wondering if it's because I'm creating buttons over again each time the screen is refreshed.

Posted: Sat Mar 22, 2003 10:31 pm
by BackupUser
Restored from previous forum. Originally posted by freak.

Yes, I think that is the problem. Also CreateGadgetList() should not be called over and over again, as it reserves Memory for the Gadget list.

You should create all the GUI by the time the window is opened, and only update the
Image several times.

You can set the new Image in the ImageGadget using SetGadgetState()

SetGadgetState(#ImageGadget, UseImage(#Image))

Hope this resolves it...

Timo

Posted: Sat Mar 22, 2003 10:34 pm
by BackupUser
Restored from previous forum. Originally posted by LJ.

Using Trace Step while watching the .exe the memory is leaking on these commands in the main DrawScreen procedure:

ImageGadget(#ImageGadget,0,0,200,600,Use Image(#image))
ButtonGadget
ClosePanelGadget()

It increases about 5K when it hits each one of these commands make it leak about 16K each time the forward or backward button is clicked. I'm guessing I need to Free all button gadgets, free all image gadgets. There is no command to free a panel gadget. Any input would be much appreciated, thanks.

Posted: Sat Mar 22, 2003 10:55 pm
by BackupUser
Restored from previous forum. Originally posted by LJ.

Unfortunately the complexity of the main code increases dramatically in later versions. Will attempt to rewrite using the #Repaint rather than Image commands.