Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Beginer code sample and questions (counting)
Page 1 of 1

PostPosted: Mon Feb 26, 2001 2:48 pm
by lbartik
I finally got somewhere with a simple counting program. I was going to post my first example and ask if anybody could help but then, I had a revalation and started again from scratch, this time, with some success. The purpose of this code is to count from 0000 to 9999 this might seem simple even for a beginer but I found it hard to include the precursory zeros. I need the initial zeros because I am trying to write a dialing program and the last time a dialed the number 0068, I didn't work dialing: 68, though pocketC might tell you that is how it's done... Eventually, the code will break the string of four numbers down into each character so each number will be dialed individually. So far, I think it will dial using wav files for each number, unless I could find a way to beep it out. Dual-tone-multi-frequeny beeps with pocketC sounds complicated to me though. Here are both examples.

But first, with a bitter voice, I would like to thank the 40 people that gave my last post enough consideration to read it, and trust that had they actually been able to offer a response, that they would've.


P.S. If anybody could simplify or speed this sh!t (ah ha, finally outwitted the censorship algorithm) up then do feel free.

Here is the first example (failure)


int a,b,c,d;
string e,f,g,h,i;
inttostr()
{
e = (string) a;
f = (string) b;
g = (string) c;
h = (string) d;
i= e+f+g+h;
}

count()
{
while(d < 10)
{
inttostr();
putsl(i);
d++;
}
}

doc()
{
c++;
d=0;
}

dob()
{
b++;
c=0;
d=0;
}
main()
{
//string home;

a = 0;
b = 0;
c = 0;
d = 0;

showconsole();

alert
("Ready to dial!");

count();
putsl("d="+d);
while (c<9)
{
doc();
count();
}
while (b<9)
{
dob();
count();
}
}

HERE IS THE SECOND ATTEMPT (WORKS)

main()
{
int x;
string a,b,c,num;

a = "0";
b = "00";
c = "000";
x=9990;
showconsole();

while (x < 10)
{
num = /*putsl*/(c + x);
x++;
clear();
}

while (x < 100)
{
num = /*putsl*/(b + x);
x++;
clear();
}

while (x < 1000)
{
num = /*putsl*/(a + x);
x++;
clear();
}

while (x < 10000)
{
num = /*putsl*/(x);
x++;
clear();
}
putsl (num);

}

THAT'S IT FOR THE CODE

PostPosted: Mon Feb 26, 2001 6:43 pm
by wolfgang
Hello,

here's some more elegant way to add leading zeroes. The function below expects the number you want to convert, and the number of digits the result shall have (which is 4 in your case). It will return the number including leading zeroes as a string.

If you need more than 9 digits, you will need to think of some more elaborate way to do it, because an integer can only hold up to 9 digits (actually, the maximum number that can be stored is about 2000000000).

By the way, creating dial tones by replaying stored wave files is probably the only feasable solution in PocketC. it works very well. I use the same approach in my musical composition program, have a look at

http://pages.prodigy.net/gwen.and.wolfgang

Wolfgang


add_leading_zeroes (int number, int no_of_digits)
{
string s;

s=number;
s=strleft ("000000000", no_of_digits-strlen(s))+s;

return (s);
}

PostPosted: Mon Feb 26, 2001 6:44 pm
by wolfgang
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hello,

here's some more elegant way to add leading zeroes. The function below expects the number you want to convert, and the number of digits the result shall have (which is 4 in your case). It will return the number including leading zeroes as a string.

If you need more than 9 digits, you will need to think of some more elaborate way to do it, because an integer can only hold up to 9 digits (actually, the maximum number that can be stored is about 2000000000).

By the way, creating dial tones by replaying stored wave files is probably the only feasable solution in PocketC. it works very well. I use the same approach in my musical composition program, have a look at

http://pages.prodigy.net/gwen.and.wolfgang

Wolfgang


add_leading_zeroes (int number, int no_of_digits)
{
string s;

s=number;
s=strleft ("000000000", no_of_digits - strlen(s)) + s;

return (s);
}




<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>