Computer Science Canada

gui program...

Author:  Prince [ Wed Apr 16, 2003 10:35 am ]
Post subject:  gui program...

k im workin on a gui form of permutations & combinations and its not workin wen i put values into the text boxes (only finds p & c for 1 and 1 Confused )
if anyone can help it would b greatly appreciated

*note: problem solved

Author:  Dan [ Wed Apr 16, 2003 4:57 pm ]
Post subject: 

i whode help but my gui files are messed up form trying to modifley them Embarassed . hopfully some one eltes will be able to figer it out.

Author:  Prince [ Wed Apr 16, 2003 9:49 pm ]
Post subject: 

is anyone here good with gui's?

Author:  Leafs Fan [ Thu Apr 17, 2003 2:47 pm ]
Post subject: 

what school do u go to prince?

Author:  Prince [ Thu Apr 17, 2003 4:43 pm ]
Post subject: 

i go to milliken... y?

Author:  MysticAngel [ Sat Apr 19, 2003 9:09 pm ]
Post subject: 

Hey prince did u figure it out what the problem was

Author:  Blade [ Sat Apr 19, 2003 9:11 pm ]
Post subject: 

Prince wrote:
is anyone here good with gui's?

delta is awesome with gui's

Author:  Prince [ Sun Apr 20, 2003 12:54 pm ]
Post subject: 

no mystic i still havnt figured it out yet... delta if ur readin this can u plz help me out

Author:  MysticAngel [ Tue Apr 22, 2003 9:59 am ]
Post subject: 

prince.. i dont know but u know the first part of the code where u declare the variables.. n and r and then u gave it a value. maybe there's the problem. cuz u said that both the values are 1. shodnt you put it to the values that are inputed ???

Author:  Prince [ Tue Apr 22, 2003 10:05 am ]
Post subject: 

im tryin but that doesnt seem to b workin either cus now there ar other variables (that need n and r) that dont hav any values

Author:  MysticAngel [ Tue Apr 22, 2003 10:11 am ]
Post subject: 

It seems that u have given all the variables the same value (in ur case 1)
so if u change the value of n and r where u declared it to say 2, then the answer too is 2. If see if can assign the value for n and r the value that is inputed through the text box.

Author:  Prince [ Tue Apr 22, 2003 10:18 am ]
Post subject: 

how tho... im tryin to figure it out but i cant

Author:  MysticAngel [ Tue Apr 22, 2003 10:19 am ]
Post subject: 

U dont have that thing called as GetPositiveInteger do u? u think that would help?

Author:  Prince [ Tue Apr 22, 2003 10:33 am ]
Post subject: 

not in a gui... i dont think so anyway... mayb i should try that

Author:  jamez [ Tue Apr 22, 2003 1:09 pm ]
Post subject: 

hmm?

you can use the function abs which returns positive al lthe time

x:=abs(-100)
x is 100

x:=abs(100)
x is 100

Author:  Delta [ Tue Apr 22, 2003 1:49 pm ]
Post subject: 

Okay if you need some help, the best way to get my attention is to email or private message me. Your problem the code your having problems with and an explaination of your problems. My email is SSDelta_@hotmail.com so email and then I'll print it out and finish/fix it at home if I can, because I lack internet except at school.

Get back to me later if your still need help

Author:  Leafs Fan [ Tue Apr 22, 2003 1:49 pm ]
Post subject: 

Prince wrote:
i go to milliken... y?


so do i...Very Happy

Author:  Prince [ Tue Apr 22, 2003 5:09 pm ]
Post subject: 

thnx delta, ill email u if i still hav problems... leafs fan, which class r u in?

Author:  Leafs Fan [ Tue Apr 22, 2003 9:27 pm ]
Post subject: 

Mr. Lutz's period five.... u?

Author:  Prince [ Wed Apr 23, 2003 9:50 am ]
Post subject: 

lutz per. 2

Author:  Leafs Fan [ Wed Apr 23, 2003 4:56 pm ]
Post subject: 

cool.. whats ur real name?

Author:  ZeroKelvin [ Wed Apr 23, 2003 7:54 pm ]
Post subject: 

hey leaf fan guess who i am, me also in lutz period 2
im also trying to figure out the damn gui perm and combo
i need help bad Confused ...........help

Author:  Leafs Fan [ Wed Apr 23, 2003 10:19 pm ]
Post subject: 

Som1 named kelvin...lol.. post the code and maybe ill know whats wrong with it..

Author:  ZeroKelvin [ Thu Apr 24, 2003 9:43 am ]
Post subject: 

k, here's a big clue ......... tap champs
now guess
I need to noe more bout gui to come up with my own code Embarassed
told u i need help

Author:  tomako [ Thu Apr 24, 2003 9:47 am ]
Post subject: 

if ya really wana noe who he is (which i do)
just go to his site and look around 8)

Author:  ZeroKelvin [ Thu Apr 24, 2003 9:47 am ]
Post subject: 

delta, i heard that ur good at gui, can you post the fixed code up so i can take a look?
thx

Author:  Lone]2 [ Thu Apr 24, 2003 9:50 am ]
Post subject: 

a lot of people here go to milliken
cuz the teacher introduced
this site to us Rolling Eyes
heheheh

Author:  Prince [ Thu Apr 24, 2003 9:54 am ]
Post subject: 

wow, how many ppl go to milliken? and who r all these fellow milliken goers Very Happy

Author:  Asok [ Thu Apr 24, 2003 9:55 am ]
Post subject: 

lol publicity at milliken!

Very Happy

Author:  ZeroKelvin [ Thu Apr 24, 2003 10:03 am ]
Post subject: 

quit talking bout milliken and gimme the code
btw i go to milliken too

Author:  Prince [ Thu Apr 24, 2003 10:10 am ]
Post subject: 

hey, buddy, this was my topic in the first place... dont demand code wen i was the original one askin for it

Author:  Delta [ Thu Apr 24, 2003 10:11 am ]
Post subject: 

I will see what I can do
... but for the time being I have no internet except at school and sometimes on the weekend

Author:  MysticAngel [ Thu Apr 24, 2003 10:26 am ]
Post subject: 

prince in ur code what does this line mean

code:

GUI.CreateTextFieldFull (115, maxy - 60, 90, realstr (n, 0),
        NEntered, GUI.INDENT, 0, 0)
[/quote]

Author:  MysticAngel [ Thu Apr 24, 2003 10:43 am ]
Post subject: 

prince u know in ur code, the porcedures NEntered and REntered are the values that u get from the user rite? can u say like n := NEntered and r := REntered ?

Author:  Prince [ Thu Apr 24, 2003 10:48 am ]
Post subject: 

k that line creates a text field for the value to b put in... and no ur way wont work cus since procedures dont return single value, i cant get anythin out of it... i could make it a function but then im afraid i might screw up the rest of it Confused

Author:  ZeroKelvin [ Thu Apr 24, 2003 6:28 pm ]
Post subject: 

sorry............
but i need help bad Crying or Very sad

Author:  MysticAngel [ Thu May 01, 2003 9:38 am ]
Post subject: 

prince, did u try like making the variables in the calcualate procedure -- the n1 and n2 as GUI.GetText ??? try that that might work

Author:  ZeroKelvin [ Thu May 01, 2003 9:59 am ]
Post subject: 

im kinda finished, but it's not perfect
if you guys can look over it that would be great, thx
code:

import GUI in "%oot/lib/GUI"
View.Set ("graphics:400;300")
var Num1TextField, Num1Label, Num2TextField, Num2Label : int
var PermButton, ComboButton, menu, item1 : int
var num1, num2 : int
var text1, text2 : string

% ========== Procedure Nothing ==========
procedure Nothing (nothing : string)
    % Does nothing
end Nothing

% ========== Function Factorial ==========
function Factorial (x : int) : int
    var z : int := 1
    for y : 1 .. x
        z := y * z
    end for
    result z
end Factorial

% ========== Function Permutation ==========
function Permutation (x, y : int) : real
    result Factorial (x) / Factorial (x - y)
end Permutation

% ========== Function Combination ==========
function Combination (x, y : int) : real
    result Factorial (x) / (Factorial (y) * Factorial (x - y))
end Combination

% ========== Procedure QuitPressed ==========
procedure QuitPressed
    GUI.Quit
end QuitPressed

% ========== Procedure PermPressed ==========
procedure PermPressed
    num1 := strint (GUI.GetText (Num1TextField))
    num2 := strint (GUI.GetText (Num2TextField))
    locate (17, 10)
    put "                                                           "
    locate (17, 10)
    if num1 >= num2 and num1 > 0 and num2 > 0 then
        put "The Permutation is ", Permutation (num1, num2)
    else
        put "Incorrect Data - Try Again"
    end if
end PermPressed

% ========== Procedure ComboPressed ==========
procedure ComboPressed
    num1 := strint (GUI.GetText (Num1TextField))
    num2 := strint (GUI.GetText (Num2TextField))
    locate (17, 10)
    put "                                                           "
    locate (17, 10)
    if num1 >= num2 and num1 > 0 and num2 > 0 then
        put "The Combination is ", Combination (num1, num2)
    else
        put "Incorrect Data - Try Again"
    end if
end ComboPressed

% ----------========== Main Program ==========----------

menu := GUI.CreateMenu ("File")
item1 := GUI.CreateMenuItem ("Quit", GUI.Quit)
Num1Label := GUI.CreateLabelFull (50, 230, "First Number", 100, 0,
    GUI.CENTER, 0)
Num1TextField := GUI.CreateTextFieldFull (50, 200, 100, "", Nothing,
    GUI.INDENT, 0, 0)
Num2Label := GUI.CreateLabelFull (250, 230, "Second Number", 100, 0,
    GUI.CENTER, 0)
Num2TextField := GUI.CreateTextFieldFull (250, 200, 100, "", Nothing,
    GUI.INDENT, 0, 0)
PermButton := GUI.CreateButton (75, 150, 100, "Permutations", PermPressed)
ComboButton := GUI.CreateButton (225, 150, 100, "Combinations", ComboPressed)

loop
    exit when GUI.ProcessEvent
end loop
cls
var quitMessage := GUI.CreateLabelFull (0, 0, "Execution Terminated", maxx,
    maxy - 135, GUI.CENTER + GUI.MIDDLE, 0)
delay (1000)
Window.Hide (defWinID)

thx again

Author:  Prince [ Thu May 01, 2003 10:24 am ]
Post subject: 

WOOHOOOOOOOOOOO!!!!!!!!!!! ive finally figured this sonofabitch out... thnx in large part to my teacher, the GUI guide on holt software's website and MysticAngel's idea of Gui.GetText... y i couldnt figure out sumthin so simple wen i started this damn thing i dont kno Confused

Author:  Prince [ Thu May 01, 2003 10:28 am ]
Post subject: 

its still not workin perfectly Evil or Very Mad ... but at least its workin now Smile

*note: problem solved

Author:  ZeroKelvin [ Thu May 01, 2003 10:34 am ]
Post subject: 

you're program is working fine but all you need to do is to clear the label
i did it the stupid way (take a look at my program above)
i see if you can find a better way

Author:  Office of the Registar [ Fri May 02, 2003 8:43 am ]
Post subject: 

its still crashable; according to rubric
you have to edit the inputs still

Author:  ZeroKelvin [ Fri May 02, 2003 9:47 am ]
Post subject: 

yo, Office of the Registar, which program are you talking bout?
me or prince? Question

Author:  Prince [ Fri May 02, 2003 9:58 am ]
Post subject: 

well if u go by everything the rubric says yea its still crashable... but theres still error checking in it (if r is greater than n it switches the two around, got that idea from sumone on this board Wink ) but other then that and the fact that the stupid label at the bottom wont clear its perfect

Author:  ZeroKelvin [ Fri May 02, 2003 10:20 am ]
Post subject: 

take a look at my program, i've found a way to clear the label
but see if you can find a better way to do it

Author:  Office of the Registar [ Fri May 02, 2003 10:25 am ]
Post subject: 

just use strintok to check it

Author:  Prince [ Fri May 02, 2003 10:28 am ]
Post subject: 

i do use it Confused

Author:  ZeroKelvin [ Fri May 02, 2003 10:37 am ]
Post subject: 

but it still crashes if you enter text instead of numbers,
how do you fix that problem? Sad

Author:  Office of the Registar [ Fri May 02, 2003 10:39 am ]
Post subject: 

what do you mean
use strintok with an if statement

Author:  ZeroKelvin [ Fri May 02, 2003 10:45 am ]
Post subject: 

that's wut Prince did, look at his program Evil or Very Mad

Author:  Office of the Registar [ Fri May 02, 2003 1:49 pm ]
Post subject: 

actually,
stintok is used only when you enter a value in the text box and press enter

you didn't use it in your procedure in which calculates the permutation/combination to check if the user entered feasible data without pressing enter and calling up the procedure

Author:  Drakonius [ Mon May 05, 2003 9:57 am ]
Post subject: 

check the topic i started earlier, that was like a long version of strintok that didn't crash

Author:  vexd [ Mon Nov 10, 2003 7:03 pm ]
Post subject: 

omg hey kiddos, now that ur all in gr12, im in gr11 Smile

well anyways LOL if u failde comp sci and are taking it again, lemme knowi aced all this ... :)ill post the code if you need it


and if it isnt obvious...i goto milliken also, and no teacher told me about this site... *shock*

neways yea, hi milliken ppl Smile


: