|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1636 |
If/Then Error. |
le 18/04/2009 @ 21:31 par mylifedrive
|
What is wrong with this line?
if A(%LOP%)-A(1) then goto _TryAgainLabel
The A() array has been dimensioned, and _TryAgainLabel exists. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 19/04/2009 @ 12:41 par aldweb
visiteur |
Hello,
Explanations about the issue you face are explained in the FAQ of the user manual, paragraph Complex tests in conditional statements.
Your line should be converted like this:
B=A(%LOP%)-A(1) : IF B>0 GOTO _TryAgainLabel
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 19/04/2009 @ 21:44 par mylifedrive
visiteur |
Thanks. That helped. Please can you now tell me what is wrong with this code? I get a number stack overflow when I run the program.
I cannot seem to post my code here unless I post the .ibas.pdb
I have uploaded it to my own site. Here is the link:
http://sitebuilder.yola.com/sites/D575/D3f9/D130/De40/U8a4986c81c03c820011c04e0319f3575/8a4986c81c03c820011c235db0560e30/resources/Mini%20Cash%20Case.ibas.pdb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3 -------- le 20/04/2009 @ 21:07 par aldweb
visiteur |
Hello,
Your mistake is at the beginning of the events loop. Just after the repeat statement, you do some calculations with %BTN$ which is not filled with a value until the user clicks on one button. So %BTN$="". Then %BTN%=0 and A(%BTN%) is A(0) which is out of range, thus bringing the number stack overflow. Well, that is my guess from reading quickly your source code. All of these lines between the repeat and the %EVT%=WAITEVENT lines should be put in a gosub/return procedure and called only after the user clicked on one button.
Cheers, aldweb
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 4 -------- le 21/04/2009 @ 04:52 par mylifedrive
visiteur |
Thanks, that worked. But now... *sigh* I have another problem. My program freezes up when I run it and I am forced to reset. I am thinking persaps somehow there is an infinite loop here:
WHILE %LOP% <> 9
%LOP% = %LOP% + 1
_TryAgainLabel:
%VLU% = RND(8)
if %VLU%=0 then %VLU%=1
end if
A(%LOP%)=%VLU%
%AARRAY% = A(%LOP%)
if %LOP% = 1 then goto _one : End If
%AARRAY2%=A(1) : if %AARRAY%=%AARRAY2% then goto _TryAgainLabel :end if
_one:
if %LOP% = 2 then goto _two : End If
%AARRAY2%=A(2) : if %AARRAY%=%AARRAY2% then goto _TryAgainLabel :end if
_two:
if %LOP% = 3 then goto _three : End If
%AARRAY2%=A(3) : if %AARRAY%=%AARRAY2% then goto _TryAgainLabel :end if
_three:
if %LOP% = 4 then goto _four : End If
%AARRAY2%=A(4) : if %AARRAY%=%AARRAY2% then goto _TryAgainLabel :end if
_four:
if %LOP% = 5 then goto _five : End If
%AARRAY2%=A(5) : if %AARRAY%=%AARRAY2% then goto _TryAgainLabel :end if
_five:
if %LOP% = 6 then goto _six : End If
%AARRAY2%=A(6) : if %AARRAY%=%AARRAY2% then goto _TryAgainLabel :end if
_six:
if %LOP% = 7 then goto _seven : End If
%AARRAY2%=A(7) : if %AARRAY%=%AARRAY2% then goto _TryAgainLabel :end if
_seven:
if %LOP% = 8 then goto _eight : End If
%AARRAY2%=A(8) : if %AARRAY%=%AARRAY2% then goto _TryAgainLabel :end if
_eight:
WEND
What I am trying to do is get the array A() to hold the numbers 1-8 randomly in the 1-8 sections. But I am having trouble, sorry. |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 5 -------- le 27/04/2009 @ 16:31 par mylifedrive
visiteur |
Bump? :D |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 6 -------- le 27/04/2009 @ 21:22 par aldweb
visiteur |
No more bump!
' Mini Cash Case.ibas
' Listing generated by ViziBasic v2.1 ' 17/04/2009 @ 18:04:37
{CREATORID "WTVr"} {VERSION "0.1"} '{MINOSVERSION "3.0"} '{PARSER OFF} '{KEYEVENTS OFF} '{SECUREFILES ON} '{CONSOLEFONT ON}
DIM %EVT%,%P1%,%P2%,%P3% DIM %P1$,%P2$,%P3$,%BTN%,%AARRAY$ DIM %BTN$,%TXT$,%VLU%,%LOP% DIM A(80) DIM %AARRAY%,%AARRAY2%
_Clicky: %TXT$="You clicked case #"+%BTN$ UPDATELABEL #9,%TXT$ %BTN% = VAL(%BTN$)
%AARRAY2% = A(%BTN%) %AARRAY$ = STR$(%AARRAY2%,0) %TXT$="It was worth $" + %AARRAY$ UPDATELABEL #10,%TXT$ %EVT%=WAITEVENT RETURN
_TryAgainLabel: %LOP% = %LOP% + 1 %VLU% = RND(8) if %VLU%=0 let %VLU%=1 A(%LOP%)=%VLU% %AARRAY% = A(%LOP%) return
BEGIN GOSUB _OnAppStart %P1$="This is just a *very* rough draft¶¶v.0.1" ABOUTBOX %P1$ GOSUB _GenerateGUI
A(1)=0
WHILE %LOP% <> 9 gosub _TryAgainLabel %AARRAY2%=A(1) : if %AARRAY%=%AARRAY2% gosub _TryAgainLabel %AARRAY2%=A(2) : if %AARRAY%=%AARRAY2% gosub _TryAgainLabel %AARRAY2%=A(3) : if %AARRAY%=%AARRAY2% gosub _TryAgainLabel %AARRAY2%=A(4) : if %AARRAY%=%AARRAY2% gosub _TryAgainLabel %AARRAY2%=A(5) : if %AARRAY%=%AARRAY2% gosub _TryAgainLabel %AARRAY2%=A(6) : if %AARRAY%=%AARRAY2% gosub _TryAgainLabel %AARRAY2%=A(7) : if %AARRAY%=%AARRAY2% gosub _TryAgainLabel %AARRAY2%=A(8) : if %AARRAY%=%AARRAY2% gosub _TryAgainLabel WEND
GOSUB _EventsLoop GOSUB _OnAppExit END
_GenerateGUI: %P1$="#1" SETFONT 0 BUTTON #1,%P1$,5,20,15,15 %P1$="#2" SETFONT 0 BUTTON #2,%P1$,25,20,15,15 %P1$="#3" SETFONT 0 BUTTON #3,%P1$,45,20,15,15 %P1$="#4" SETFONT 0 BUTTON #4,%P1$,65,20,15,15 %P1$="#5" SETFONT 0 BUTTON #5,%P1$,5,40,15,15 %P1$="#6" SETFONT 0 BUTTON #6,%P1$,25,40,15,15 %P1$="#7" SETFONT 0 BUTTON #7,%P1$,45,40,15,15 %P1$="#8" SETFONT 0 BUTTON #8,%P1$,65,40,15,15 %P1$="You clicked case ..." SETFONT 0 LABEL #9,%P1$,5,60 %P1$="It was worth..." SETFONT 0 LABEL #10,%P1$,5,60 RETURN
_EventsLoop:
REPEAT %EVT%=WAITEVENT SELECT CASE %EVT% CASE 1 GOSUB _BUTTON_1 CASE 2 GOSUB _BUTTON_2 CASE 3 GOSUB _BUTTON_3 CASE 4 GOSUB _BUTTON_4 CASE 5 GOSUB _BUTTON_5 CASE 6 GOSUB _BUTTON_6 CASE 7 GOSUB _BUTTON_7 CASE 8 GOSUB _BUTTON_8 END SELECT UNTIL %EVT%=-1 RETURN
_BUTTON_1: %BTN$="1" GOSUB _Clicky RETURN
_BUTTON_2: %BTN$="2" GOSUB _Clicky RETURN
_BUTTON_3: %BTN$="3" GOSUB _Clicky RETURN
_BUTTON_4: %BTN$="4" GOSUB _Clicky RETURN
_BUTTON_5: %BTN$="5" GOSUB _Clicky RETURN
_BUTTON_6: %BTN$="6" GOSUB _Clicky RETURN
_BUTTON_7: %BTN$="7" GOSUB _Clicky RETURN
_BUTTON_8: %BTN$="8" GOSUB _Clicky RETURN
_OnAppStart:
RETURN
_OnAppExit:
RETURN |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 7 -------- le 28/04/2009 @ 22:32 par Gary
visiteur |
In the code below you have %p1$="something" and you setfont to 0 then you display the button
Do you need to setfont on each button?
And is it better to let a variable equal something instead of BUTTON #1,"SOMETHING",T,L,W,H
_GenerateGUI: %P1$="#1" SETFONT 0 BUTTON #1,%P1$,5,20,15,15 %P1$="#2" SETFONT 0 BUTTON #2,%P1$,25,20,15,15 %P1$="#3" SETFONT 0 BUTTON #3,%P1$,45,20,15,15 %P1$="#4" SETFONT 0 BUTTON #4,%P1$,65,20,15,15 %P1$="#5" SETFONT 0 BUTTON #5,%P1$,5,40,15,15 %P1$="#6" SETFONT 0 BUTTON #6,%P1$,25,40,15,15
Thanks Gary |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 8 -------- le 28/04/2009 @ 22:37 par aldweb
visiteur |
No, it is not needed.
BUTTON #1,"SOMETHING",T,L,W,H is a better syntax.
But, the original source code was generated by the ViziBasic add-on which is a little bit less optimized than hand-made coding...
Cheers, aldweb
|
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|