English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 30 April 2009, 02:14   #1
AlfaRomeo
A1200 040 SAM440EP 667
 
AlfaRomeo's Avatar
 
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
BlitzBasic problem

Hello there,
I´m writing a little program to calculate resistor values in AmiBlitz3 but
when I run the following program to test, it gives me the error Label reference out of context at program line in bold. If used Goto _color instead Gosub _color, same error happens Can someone explain me why this error and how to jump to the subroutine??
Thanks in advance

WBStartup
WbToScreen 0
Use Screen 0

Statement Requester{}
GTString 0,1,24,17,60,14,"",0,8:GTInteger 0,4,140,51,70,14,"",0,0
GTString 0,2,24,34,60,14,"",0,8
GTString 0,3,24,51,60,14,"",0,8
GTCycle 0,5,110,7,140,14,"",0,"Cores->Valores|Valores->Cores|"

Window 0,100,100,280,100,$08 | $02,"Resistor Colors",1,2,0
AttachGTList 0,0

WLocate 37,04:Print "Cores":WLocate 130,37:Print "Valor em ohms"
WLocate 4,17:Print "1a":WLocate 4,34:Print "2a":WLocate 4,51:Print "3a"
End Statement

Statement Togle{}
Repeat
ev.l=WaitEvent
If ev=$40 AND GadgetHit=1 OR GadgetHit=2 OR GadgetHit=3
col1$=GTGetString(0,1) : col2$=GTGetString(0,2):col3$=GTGetString(0,3)
Gosub _color
EndIf
If ev=$40 AND GadgetHit=4
Gosub _valor
EndIf
Until ev=$200
End Statement

._color
WLocate 4,17:Print col1$:WLocate 4,34:Print col2$:WLocate 4,51:Print col3$
Return

._valor
Repeat
ev.l=WaitEvent
If ev=$40
v=GTGetInteger(0,4)
EndIf
Until ev=$200
Return

Statement Main{}
Requester{}
Togle{}
MouseWait
CloseWindow 0
Free GadgetList 0
End Statement

Main{}
AlfaRomeo is offline  
Old 30 April 2009, 06:20   #2
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,400
I know nothing about basic (well apart from the fact that I hate it) but you could try moving that subroutine above the calling block.
NovaCoder is offline  
Old 30 April 2009, 09:02   #3
clenched
Registered User
 
Join Date: Sep 2008
Location: Gainesville U.S.A.
Posts: 771
I don't keep up with the new-fangled BASIC's either but make these changes and at least you'll not be looking at the SAME error.

Until ev=$200
goto jail
._color
WLocate 4,17:Print col1$:WLocate 4,34:Print col2$:WLocate 4,51:Print col3$
Return
._valor
Repeat
ev.l=WaitEvent
If ev=$40
v=GTGetInteger(0,4)
EndIf
Until ev=$200
Return
jail: End Statement
Statement Main{}
clenched is offline  
Old 30 April 2009, 09:11   #4
TCD
HOL/FTP busy bee
 
TCD's Avatar
 
Join Date: Sep 2006
Location: Germany
Age: 46
Posts: 31,525
Found on the net :

Quote:
> ; BUG3. Trying to jump into a subthingy
>
> Statement a{}
> Goto subroutine ; LABEL REFERENCE OUT OF CONTEXT
> End Statement
>
> End
>
> subroutine
> Return
>
> ; I think that something to do with the prosessors stack ?

This is illegal, since it negates the benefits of having statements -
inside a statement, there should be no code visible from the main program
when inside a statement or function. There should (will) be no variables
visible from the main program either (unless they're shared). If you
want to branch outside, then use a subroutine instead of a statement.
Hope it helps
TCD is offline  
Old 30 April 2009, 18:18   #5
AlfaRomeo
A1200 040 SAM440EP 667
 
AlfaRomeo's Avatar
 
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
Thanks for the help guys

@TheCyberDruid
With your help I could solve the problem
"there should be no code visible from the main program when inside a statement or function"
Thanks dude
AlfaRomeo is offline  
Old 01 May 2009, 10:58   #6
TCD
HOL/FTP busy bee
 
TCD's Avatar
 
Join Date: Sep 2006
Location: Germany
Age: 46
Posts: 31,525
You are welcome Alfa Good to hear it worked this way
TCD is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
REQ: Amiga Format - BlitzBasic Tutorials AlfaRomeo AMR suggestions and feedback 23 20 February 2012 18:25
From the makers of BlitzBasic: Monkey... now with OS3.x and AROS support HenryCase News 13 14 January 2012 05:33
Anyone still writing games with BlitzBasic ?? Joe Maroni Coders. General 0 17 November 2008 22:26
BlitzBasic (PC) LaundroMat Coders. General 9 23 June 2003 09:14
BlitzBasic - Is now open source Djay Amiga scene 2 08 February 2003 01:09

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 14:36.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.25657 seconds with 15 queries