C++ builder question..

T

Torbjørn Morka

I am currently working with a small program using BCB 6, and this is
my question.
When clicking the button
the code is this...:
//--------------------------------------------------------------------
-------
void __fastcall TForm1::Button1Click(TObject *Sender)

etc...
everything here below was fine.

//--------------------------------------------------------------------
-------

far above this i use the Randomize-call, with success, right after the
declaration
of the Form itself.
Now, in my little program there are 4 smaller procedures or functions.
Beeing intil now used to Delphi, i found out that it was not quite the
same...

procedure 1 is the code written for Button1, and that piece was
ok.(creating a random number)
procedure 2 is to check for equals in an array,
procedure 3 is to check for numbers greater than the
following(bubblesorting)
procedure 4 is to swap numbers.

HOW do i declare a procedure/function, and WHERE do i put the code ??

I obvious can not say

for (a = 0; a < 8; a++ ) { //
number[a] = (random(99) + 1) ;
}

// now i want to call this one
bubblesort; //supposed to be calling the function/procedure...
or
bubblesort();

huh ??

I want to fill in the blanks for my self, but the correct declaration
is apreciated...

Torbjorn.
 
V

Victor Bazarov

Torbjorn Morka said:
I am currently working with a small program using BCB 6, and this is
my question.
When clicking the button
the code is this...[...]

I think you'll be much better off asking in a BCB-specific newsgroup.
Try 'borland.public.cppbuilder.language' or something similar.
 
T

Torbjørn Morka

"Victor Bazarov" <[email protected]> skrev i melding
: >I am currently working with a small program using BCB 6, and this
is
: > my question.
: > When clicking the button
: > the code is this...[...]
:
: I think you'll be much better off asking in a BCB-specific
newsgroup.
: Try 'borland.public.cppbuilder.language' or something similar.
:

My ISP does not have any such group... :-(

Torbjorn.
:
 
E

Edernity

try google (groups.google.com)
Edernity
--------
if it help (IT DON'T CAUSE YOU A CENT. JUST 1 EMAIL THEN FILLING FORMS)
please do help me provide better school supplies for childrenof
indonesia.
IN FACT, for those other who already read this plea and maybe finding
my post helpful, what is I give you one dollars for it. I don't believe
this, I'm paying to get people to donate to kids?!!!???that really
ugly!
it may be a donation but I merely ask you to letme send email to you
from one of the product of I'm affiliated and please register there on
mechant account free. If you even want you refund back on your dollar
of i-kard, its ok, I'll send you just use regular delivery on shipping
please. Please note this is very safe since this is a bonafid company.
remember your credit card company will confirm you on your purchase.
u can add or remove more credit cards into your account. you can/should
also ask for always confirmation on send out to you. That will get
those savage cracker bloke out. even u can use some more free teen
refillable visa/mastercard from your bank cc account (can be obtaion
free).
It is just unnerving seeing how can people do not do anything as so
they need so little. $10 could support {{{{{the child 1 month.}}}}
Still have doubts, sign on a personal account and let me contact you
again on it. just one mail pls
also
I'm also affiliated to this site:
www.getaportal.com/portals/eddy_ruslim
Unless u wanto e-gold it at 1369872
New to egold:www.e-gold.com/e-gold.asp?cid=1369872
NAH, previous way cost u zilch
God bless
 
I

Ioannis Vranos

Torbjørn Morka said:
: I think you'll be much better off asking in a BCB-specific
newsgroup.
: Try 'borland.public.cppbuilder.language' or something similar.
:

My ISP does not have any such group... :-(

Torbjorn.


And they are much inactive anyway. The better way is to use the Borland
web newsgroups, which are free to use and can find them in Borland's web
site:

http://www.borland.com
 
A

Alf P. Steinbach

* Torbjørn Morka:
I am currently working with a small program using BCB 6, and this is
my question.
When clicking the button
the code is this...:
//--------------------------------------------------------------------
-------
void __fastcall TForm1::Button1Click(TObject *Sender)

etc...
everything here below was fine.

//--------------------------------------------------------------------
-------

far above this i use the Randomize-call, with success, right after the
declaration
of the Form itself.

You should put that in the program's 'main' or a function called by
'main'.

Now, in my little program there are 4 smaller procedures or functions.
Beeing intil now used to Delphi, i found out that it was not quite the
same...

procedure 1 is the code written for Button1, and that piece was
ok.(creating a random number)
procedure 2 is to check for equals in an array,
procedure 3 is to check for numbers greater than the
following(bubblesorting)
procedure 4 is to swap numbers.

HOW do i declare a procedure/function, and WHERE do i put the code ??

I obvious can not say

for (a = 0; a < 8; a++ ) { //
number[a] = (random(99) + 1) ;
}

// now i want to call this one
bubblesort; //supposed to be calling the function/procedure...
or
bubblesort();

huh ??

I want to fill in the blanks for my self, but the correct declaration
is apreciated...

It's very difficult to answer when you don't show any of the code, but
generally the initialization should go in a constructor, in your case
presumably TForm1::TForm1.
 
T

Torbjørn Morka

"Alf P. Steinbach" <[email protected]> skrev i melding
: * Torbjørn Morka:
: > I am currently working with a small program using BCB 6, and this
is
: > my question.
: > When clicking the button
: > the code is this...:
: >
//--------------------------------------------------------------------
: > -------
: > void __fastcall TForm1::Button1Click(TObject *Sender)
: >
: > etc...
: > everything here below was fine.
: >
: >
//--------------------------------------------------------------------
: > -------
: >
: > far above this i use the Randomize-call, with success, right after
the
: > declaration
: > of the Form itself.
:
: You should put that in the program's 'main' or a function called by
: 'main'.
:
:
: > Now, in my little program there are 4 smaller procedures or
functions.
: > Beeing intil now used to Delphi, i found out that it was not quite
the
: > same...
: >
: > procedure 1 is the code written for Button1, and that piece was
: > ok.(creating a random number)
: > procedure 2 is to check for equals in an array,
: > procedure 3 is to check for numbers greater than the
: > following(bubblesorting)
: > procedure 4 is to swap numbers.
: >
: > HOW do i declare a procedure/function, and WHERE do i put the code
??
: >
: > I obvious can not say
: >
: > for (a = 0; a < 8; a++ ) { //
: > number[a] = (random(99) + 1) ;
: > }
: >
: > // now i want to call this one
: > bubblesort; //supposed to be calling the function/procedure...
: > or
: > bubblesort();
: >
: > huh ??
: >
: > I want to fill in the blanks for my self, but the correct
declaration
: > is apreciated...
:
: It's very difficult to answer when you don't show any of the code,
but
: generally the initialization should go in a constructor, in your
case
: presumably TForm1::TForm1.
:
TForm1 *Form1;
//--------------------------------------------------------------------
-------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Randomize;
}
//--------------------------------------------------------------------
-------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
int lottotall[6];
int i, a, j, temp;


for (i = 0; i < 6; i++) {
lottotall = 0; //empty the array
lottotall = random(48)+1; //6 random numbers
}


{
int a, j, temp;// this is supposed to be sorting routine, not
functional...
do
for(a = 0; a < 6; a++) {

for (j = 0; j < 6; j++) {
if (lottotall[a] > lottotall[a+1])
{
temp = lottotall[j];
lottotall[j] =
lottotall[j+1];
lottotall[j+1] = temp;
}
}
}
while (lottotall[a] > lottotall[a+1]);
}
Edit1->Text = lottotall[0];
Sleep(100);
Application->ProcessMessages();
Edit2->Text = lottotall[1];
Sleep(100);
Application->ProcessMessages();
Edit3->Text = lottotall[2];
Sleep(100);
Application->ProcessMessages();
Edit4->Text = lottotall[3];
Sleep(100);
Application->ProcessMessages();
Edit5->Text = lottotall[4];
Sleep(100);
Application->ProcessMessages();
Edit6->Text = lottotall[5];
Sleep(100);
Application->ProcessMessages();
}

The ideal was
Do the random picking of numbers
Check if someone are equal, if so do it again.
If not check if number[a] > number[a+1], if not compare with all the
rest
(must compare with some Delphi i did previous)

Torbjorn.

: --
: A: Because it messes up the order in which people normally read
text.
: Q: Why is it such a bad thing?
: A: Top-posting.
: Q: What is the most annoying thing on usenet and in e-mail?
Some kind of signatures too...
 
D

Duane Hebert

Torbjørn Morka said:
"Victor Bazarov" <[email protected]> skrev i melding
: >I am currently working with a small program using BCB 6, and this
is
: > my question.
: > When clicking the button
: > the code is this...[...]
:
: I think you'll be much better off asking in a BCB-specific
newsgroup.
: Try 'borland.public.cppbuilder.language' or something similar.
:

My ISP does not have any such group... :-(

newsgroups.borland.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,271
Latest member
BuyAtenaLabsCBD

Latest Threads

Top