|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1253 |
Newbie REDUX |
le 05/09/2005 @ 21:13 par Shawn
|
Okay, I've restarted this topic, just so it's easier to read.
I copied code from the examples out of the forum and I get syntax errors. My frustration with learning IZ is that there is no "code examples” I understand that you have put a lot of time and effort in to this program, and it truly shows. The manual is pretty good, and shows that a lot of work went into it as well. The only thing is that it shows syntax and not examples. I know maybe I'm asking a lot, and that's why I turned to the forum for examples and help. I know it's frustrating when someone will ask the forum a question that is clearly in the manual. Just keep in mind that some of us need a little more direction than the manual gives. I have printed the 103 paged manual and refer to it often. Alright enough said.
Here is my code, I STILL get a syntax error on the STR$(c$,0) line. I added the ,0 after your last posting and still no go.
' GUI.IBAS {CREATORID "SPH9"}
BEGIN TITLE "GUI MATH" TEXTFIELD #1,"0",0,15,25,50,10 TEXTFIELD #2,"0",0,15,45,50,10 BUTTON #3,"calculate",5,85,50,14 REPEAT E=DOEVENTS IF E=3 GOSUB _CalcIt : E=-1 UNTIL E=-1 END _CalcIt: A$=FIELD$(#1) B$=FIELD$(#2) A=VAL(A$) B=VAL(B$) C=A/B C$=STR$(C$,0) MESSAGEBOX(C$,0) RETURN
Thanks again for all your hard work and time you have put into this pgrogram for all of us to enjoy.
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 05/09/2005 @ 21:51 par aldweb
visiteur |
Hello Shawn,
It is a good idea to start a new topic, thanks.
Indeed the iziBasic implementation of STR$() is not very standard. I did it on purpose to ease the output formatting of numbers to a text string. So there was a trick anyway! And I have to acknowledge that my former answer was too fast, not very friendly. I wrote it very quickly, without thinking too much about it. I apologize for that.
I also understand your frustration because of the lack of "code examples". Please allow me to just say that iziBasic is a hobby project for me, not my job, and it is a "one man" project. So putting code examples for all single statements and functions is too much work for me. This is why I took the option of providing so many full source code sample programs instead.
Now, the exact syntax of STR$ is : textvar=STR$(number,format) Indeed, you want to convert a numeral value into a string with a given format. So, replace your C$=STR$(C$,0) line by this one: C$=STR$(C,0). You may also enhance a little bit your application by replacing the C=A/B line by this one: C=AB since the 0 format you used in the STR$() function says that you want to display only the integer part of the number. So, an integer division would work just as fine and save you a few processor ticks.
Never hesitate to ask for more help. This forum is the right place indeed to ask for help and to share good ideas and good pieces of source code.
Thank you for your last sentence. This is the best reward I can get for this first compiler project I ever worked on, as a hobby, for the fun of it.
Cheers
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2 -------- le 05/09/2005 @ 21:57 par aldweb
visiteur |
Sorry, I missed another mistake in your source code when reading it.
MESSAGEBOX is also a function, so, in iziBasic, it is a must to put its return value in a variable, even a fake one that you don't use afterwards.
So, also replace MESSAGEBOX(C$,0) by somethink like: M=MESSAGEBOX(C$,0)
Cheers,
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3 -------- le 05/09/2005 @ 22:48 par Shawn
visiteur |
Wow thanks for the quick response, and again thanks for your help and efforts.
I made the changes and all works. But this "app" was more of a learning curve.
Now, if you have time....
Why can't I use NUMFIELD instead of TEXTFIELD to get the numbers from the user?
The applications I want to create all deal with math equations and having to convert text to number and back again, is alot of effort if numfield would work.
thanks again.
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 4 -------- le 06/09/2005 @ 11:13 par aldweb
visiteur |
Hello Shawn,
When I replace the TEXTFIELD lines by NUMFIELD in your sample source code, everything works fine. So, maybe provide a few more explanations of what does not work for you...
Cheers, aldweb |
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|