English Amiga Board Amiga Lore


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 06 June 2017, 23:07   #1
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 167
bug with Blitz Basic 2

Blitz basic 2 is literally stopping me from writing my simple tic tac toe project due to it's horrendous bugs. One of the bugs is the IF statement and Select statement. I will report you my bugs in point list.
  • If statement only works ones
  • If you have more than one if statement the other if statements will never trigger even if the conditions are true
  • else statement always excutes even if the condition is false
  • I removed the IF statements and put Select statement. Select statement behave better than if statement, however there are errors on it too. For example if I have an IF statement that checks If normal=1 and Gameb(1)=16 in the select statement need to put Select Gameb(1) Case 16: select normal case 1:<put code here> ..problem with this also is that it too only triggers one.

Pretty much I want when the person selects the menu and presses for example grid size that if statements waits for the user's input to press the button and compare the true condition with the button with the normal being equal to 1 also to equal true before it triggers inside of it. But it only triggers it ones.

Another problem I have with the if condition is that sometimes it fires at the beginning of the execution of the game which instead of being in the title screen it goes right to game play. I have to stop the program and recompile it and run it again before I start with the menu screen and click new Game to fire the game play.

Problem is..if I stop the program and compile it again it fires instantly and start the game..I have to quit it and recompile again before it starts in the title screen.

This issue is constant and it is annoying. Blitz basic 2 is filled with annoying bugs that literally just make me want to throw it in the trash. I am wondering, are all these annoying bugs resolved in amiblitz 3? Because amiblitz 2 have these exact same bugs. Many reasons why I am a little distant form using the programming language.
xboxown is offline  
AdSense AdSense  
Old 06 June 2017, 23:49   #2
Dunny
Registered User

Dunny's Avatar
 
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 740
Quote:
Originally Posted by xboxown View Post
[*]else statement always excutes even if the condition is false
Isn't that exactly what an ELSE clause is supposed to do?
Dunny is offline  
Old 07 June 2017, 00:36   #3
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 167
Quote:
Originally Posted by Dunny View Post
Isn't that exactly what an ELSE clause is supposed to do?
Sorry. I was hastily typing..I mean to say it executes it regardless of condition. Blitz basic 2 is buggy. f there is a programming language in windows where I can just compile it to Amga 68k and use winuae to test things I would do it.
xboxown is offline  
Old 07 June 2017, 00:53   #4
Foul
Registered User

Foul's Avatar
 
Join Date: Jun 2009
Location: Perigueux/France
Age: 42
Posts: 1,256
Send a message via ICQ to Foul Send a message via MSN to Foul Send a message via Skype™ to Foul
ASM with vasm ?
Foul is offline  
Old 07 June 2017, 01:16   #5
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 46
Posts: 359
Ummm, can you show us a simple small source code with an "if" that displays such behavior?
alkis is offline  
Old 07 June 2017, 07:25   #6
tolkien
AmigaMan

tolkien's Avatar
 
Join Date: Oct 2012
Location: Castro Urdiales/Spain
Posts: 443
Blitz basic has been used for years in a lot of projects. Is strange that those important commands (if and select) are buggy.
Would be interesting a short example were it fails.
tolkien is offline  
Old 07 June 2017, 08:13   #7
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 167
Here is the source code entirely! I am intending to make this game open source anyways. Observe how as soon as you run the game it goes right to the game play instead of title screen. As if someone pushed the button when I didn't. Very buggy in the if and select statement. Yet when you run it again it goes to title screen. By the way I discovered something else.

If I have more than one if statement following each other..the 1st if statement get executed but the others get skipped even if there where no else statement and even if the conditions for the second if statements are true. It can only execute one if statement in the entire project. So i really need to know if amiblitz3 have all these problems and bugs fixed.
Attached Files
File Type: rar TicTacToe.rar (1.7 KB, 25 views)
xboxown is offline  
Old 07 June 2017, 09:51   #8
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,055
I think there must be something wrong with your code - something as simple as an If statement not working would absolutely cripple a language, whereas there are thousands of Blitz projects out there working just fine. I myself have used If statements nested many levels deep without issues.

I unfortunately don't have WinRAR here so I can't open your source - perhaps you could paste it into a code box instead? Anyway, without seeing the actual code, my guess would be that the issue is possibly due to confusion over variable typing or perhaps over syntax. Either way, I'm sure it will be simple to sort out.

Edit: Managed to unpack the source, but it's tokenised so I can't read it properly here. Using a code box will help that anyway, as would saving it as ASCII and attaching it without compressing.
Daedalus is offline  
Old 07 June 2017, 12:35   #9
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 2,977
I see some problems here:

First of all, the semantics of Select … Case X AND Y are suspicious.

Secondly, you leave a Select statement with a Goto. I think you must Pop your Select before doing that, or your call stack will be out of order.
idrougge is offline  
Old 07 June 2017, 13:46   #10
ExiE
Registered User

 
Join Date: Apr 2016
Location: T/C
Posts: 41
As my friend use to say: "I would search for the bug between chair and keyboard" :-D
Error in such basic command like IF is highly unlikely...

Can you please attach the code in ascii format?
ExiE is offline  
Old 07 June 2017, 18:14   #11
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 167
Quote:
Originally Posted by ExiE View Post
As my friend use to say: "I would search for the bug between chair and keyboard" :-D
Error in such basic command like IF is highly unlikely...

Can you please attach the code in ascii format?

How do you do it? Unless I have to retype code by code by looking at the tv and looking at the monitor I don't know how I about sending it to you in ascii format? Couldn't you just open the file in winuae blitz basic 2 and view it that way? It saves me so much frustration having to port it in ascii.
xboxown is offline  
Old 07 June 2017, 18:25   #12
Akira
Registered User

Akira's Avatar
 
Join Date: May 2001
Location: New York
Posts: 17,676
It does sound to me like you have something wrong in your code. There's NO WAY bugs in such fundamental commands happened to be undiscovered for so long.

You can SAVE ASCII in Blitz Basic. You could also copy in WinUAE and paste in a text editor/here by enabling clipboard sharing.

Let me do it for you this one time

Code:
#ANY=0
#CHIP=2
#FAST=4
#CLEAR=$10000
#LARGE=$20000
#TOTAL=$80000
#FLAGNOTHING=$0
#FLAGDRAGONLY=$2
#FLAGDRAGDEPTHGADGET=$3
#FLAGALL=$F
#WINDOWCLOSE=512
WBStartup ; Run through double clicking

NEWTYPE.Players
  PlayerName$
  Score.l
  Turn.b
End NEWTYPE

Dim List CurrentPlayer.Players(1)
Dim Sound_$(1):Sound_$(0)="On":Sound_$(1)="Off"
Dim GridSize_(3):GridSize_(0)=3:GridSize_(1)=6:GridSize_(2)=9:GridSize_(3)=12
Dim Mode_$(1):Mode_$(0)="Classic":Mode_$(1)="Disco"
Dim SA$(9)
GameOver=0
Gosub Initialize
Gosub Title

Game:
Repeat
;WLine 120, (640/2)*1, 240, (640/2)*1,1
;WLine 120, (640/2)*2, 240, (640/2)*2,1
WLocate 0,0:Print iGrid
For Y=0 To GridSize_(iGrid)-1
  For X=0 To GridSize_(iGrid)-1
    If iGrid=0 Then IsNum=0 Else IsNum=GridSize_(iGrid)
    WLocate 0,0:Print iGrid:WLocate 0,10:Print GridSize_(iGrid)
    Wline 111+(23*Y)*1.5,25,111+(23*Y)*1.5,142+(15*IsNum),2
    Wline 25, 45+(23*X)*1.5,215+(15*IsNum),45+(23*X)*1.5,2
  Next X
Next Y
;WLine 282,25,282,142,2
Delay_ 1
Until GameOver=1

Goto Title

Return

; Place to initialize all variables, screen, blitz, etc.
; Anything that needs one time initialization goes here
Initialize:
; Initialize player 1 setting
If AddItem(CurrentPlayer())
  CurrentPlayer()\PlayerName="Player 1"
  CurrentPlayer()\Score=0
  CurrentPlayer()\Turn=0
End If
; Initialize player 2 setting
If AddItem(CurrentPlayer())
  CurrentPlayer()\PlayerName="Player 2"
  CurrentPlayer()\Score=0
  CurrentPlayer()\Turn=0
End If
; Initialize screen, resolution, windows and background color
Screen 1,11,"Tic Tac Toe"
Window 1,0, 12, 640, 185, #FLAGNOTHING, "", 1,2
RGB 0,0,0,0
RGB 1,0,6,5
WindowOutput 1

Return

Title:
Wline 65,30, 148,30,4:Wline 106,30,106,75,4:Wline 170,30,170,75,4
S$="C  l  a  s  s  i  c             E  d  i  t  i  o  n             "

SA$(0)="New Game ":SA$(1)="Options  ":SA$(2)="Networks  ":SA$(3)="Exit   "
WLocate 80,80:Print S$
WLocate 260,100:Print SA$(0)
WLocate 260,115:Print SA$(1)
WLocate 260,130:Print SA$(2)
WLocate 260,145:Print SA$(3)

WLocate 0,0
WindowOutput 1
Repeat
VWait
Select Joyy(1)
  Case -1:
    WLocate 0,60:Print (Y+100)
    Select (Y+100) AND (nY+100)
      Case 100:
        WLocate X+240,Y+100:Print " "; clear it so no ghosting happens
        WLocate nX+332,nY+100:Print "    "; clear it so no ghosting happens
        Y=60:nY=Y
        WLocate X+240,Y+100:Print "*"
        WLocate nX+332,nY+100:Print "*"
      Case 145:
        WLocate X+240,Y+100:Print " "; clear it so no ghosting happens
        WLocate nX+332,nY+100:Print "     "; clear it so no ghosting happens
        Y=Y-15:nY=Y
        WLocate X+240,Y+100:Print "*"
        WLocate nX+332,nY+100:Print "*"
      Default:
        WLocate 80,80:Print S$
    End Select
  Case 1:
    WLocate X+240,Y+100:Print " "; clear it so no ghosting happens
    WLocate nX+332,nY+100:Print "   "; clear it so no ghosting happens
    Y=Y+15:nY=Y
    If (Y+100)>150 AND (nY+100)>150 Then Y=0:nY=0
    WLocate 80,80:Print S$

End Select
;If Joyy(1)=-1
;  If (Y+100)=100 AND (nY+100)=100
;    WLocate X+240,Y+100:Print " "; clear it so no ghosting happens
;    WLocate nX+332,nY+100:Print "    "; clear it so no ghosting happens
;    Y=60:nY=Y
;    WLocate X+240,Y+100:Print "*"
;    WLocate nX+332,nY+100:Print "*"

;  End If
;  If (Y+100)<>100 AND (nY+100)<>100
;    WLocate X+240,Y+100:Print " "; clear it so no ghosting happens
;    WLocate nX+332,nY+100:Print "     "; clear it so no ghosting happens
;    Y=Y-15:nY=Y
;    WLocate X+240,Y+100:Print "*"
;    WLocate nX+332,nY+100:Print "*"
;  EndIf
;  WLocate 80,80:Print S$
;EndIf
;If Joyy(1)=1
;  WLocate X+240,Y+100:Print " "; clear it so no ghosting happens
;  WLocate nX+332,nY+100:Print "   "; clear it so no ghosting happens
;  Y=Y+15:nY=Y
;  If (Y+100)>150 AND (nY+100)>150 Then Y=0:nY=0
;  WLocate 80,80:Print S$

;EndIf
WLocate X+240,Y+100:Print "*" ; left side selection
WLocate nX+332,nY+100:Print "*" ; right side selection

Select Y
  Case 0:
    Select Gameb(1)
      Case 16:
        Select normal
          Case 0:
            CloseWindow 1
            Window 1,0, 12, 640, 185, #FLAGNOTHING, "", 1,2
            RGB 0,0,0,0
            RGB 1,0,6,5
            Goto Game
        End Select
    End Select

  Case 15:
    Select Gameb(1)
      Case 16:
        Select normal
          Case 0:
            S5$="Sound "+Str$(Sound_$(b)):S6$=Str$(GridSize_(iGrid))
            WLocate 260,100:Print S5$
            WLocate 260,115:Print "Grid "+S6$+"x"+S6$+""
            WLocate 260,130:Print Mode_$(x)
            WLocate 260,145:Print "Return"
            normal=1
        End Select
    End Select

  Case 30:
   ; If Gameb(1)=16 AND normal=0
   ;   WLocate 80,80:Print "N  e  t  w  o  r  k      N  o  t     A  v  a  i  l  a  b  l  e!!"
   ; EndIf
End Select
Select Gameb(1)
  Case 16:
    WLocate 0,0:Print "Button pushed."
    Select normal
      Case 1:
        Select Y
          Case 0:
            Delay_ 5
            b=1-b
            S5$="Sound "+Str$(Sound_$(b))
            WLocate 260,100:Print S5$
          Case 15:
            WLocate 0,55:Print "You selected grid"
            iGrid=iGrid+1
            S6$=Str$(GridSize_(iGrid))
            WLocate 260,115:Print "Grid "+S6$+"x"+S6$+""
            Select iGrid
              Case 3:
              iGrid=0
            End Select

            normal=1:Y=15
            Delay_ 5
          Case 30:
            WLocate 260,130:Print Mode_$(x)
            x=1-x
          Case 45:
            WLocate X+240,Y+100:Print " "; clear it so no ghosting happens
            WLocate nX+332,nY+100:Print "     "; clear it so no ghosting happens
            Y=0:normal=0:nY=0
            WLocate X+240,Y+100:Print "*"; clear it so no ghosting happens
            WLocate nX+332,nY+100:Print "*"; clear it so no ghosting happens
            Goto Title
        End Select
    End Select
  Default:
  WLocate 0,0:Print "                  "
End Select
WLocate 0,30:Print "normal="+Str$(normal)+""
WLocate 0,45:Print "Y="+Str$(Y)+""
WLocate 0,55:Print "                       "
Delay_ 1
Until Gameb(1)=16 AND (Y+100)=145 AND (nY+100)=145 AND normal=0

CloseWindow 0
CloseScreen 0
End
Return

Render:
Return

Update:
Return
Where is the bug occurring?
I see that the line:
Code:
If iGrid=0 Then IsNum=0 Else IsNum=GridSize_(iGrid)
has no ENDIF.

Also at line 112
Code:
If (Y+100)>150 AND (nY+100)>150 Then Y=0:nY=0
No ENDIF again.

And there's more, I think you have a case of unclosed IF statements. Go through the code and count them.
Akira is offline  
Old 07 June 2017, 19:10   #13
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 2,977
You don't have to close one-line If statements.
idrougge is offline  
Old 07 June 2017, 19:13   #14
Akira
Registered User

Akira's Avatar
 
Join Date: May 2001
Location: New York
Posts: 17,676
There's me and my big mouth then :P Sorry!
Makes syntax confusing though.
The SELECT case at the bottom also looks a bit confusing too.
Akira is offline  
Old 07 June 2017, 19:50   #15
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 167
Quote:
Originally Posted by Akira View Post
There's me and my big mouth then :P Sorry!
Makes syntax confusing though.
The SELECT case at the bottom also looks a bit confusing too.
i only used select because if statement is not working. now both is not working so i am lost.
xboxown is offline  
Old 07 June 2017, 21:06   #16
Cylon
Registered User

 
Join Date: Oct 2014
Location: Europe
Posts: 448
I don't want to read all of it but at least this
Code:
Select (Y+100) AND (nY+100)
is not what it's intended i believe.

You are switching depending on the result

Code:
is (Y+100 AND nY+100) = TRUE (or 0)
.
Cylon is offline  
Old 07 June 2017, 21:11   #17
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 167
Quote:
Originally Posted by Cylon View Post
I don't want to read all of it but at least this
Code:
Select (Y+100) AND (nY+100)
is not what it's intended i believe.

You are switching depending on the result

Code:
is (Y+100 AND nY+100) = TRUE (or 0)
.
OK. I was not aware it is doing that. The problem with me when they where the if statement only one if statement gets executed which is the top, top line and get executed ones even after many times the conditions have being met. When I come home..I will convert them back all to if statements (the select) and paste the code here. But that is all i could do. I am not going to resume development of this project of tic tac toe..until someone here please help me point out why it is behaving like this?

Unless there is a blitz basic for windows that fixes all these issues that can compile for Amiga 68k..if this issue is not resolved I will be forced to quit this project and any amiga development as there are really no decent programming language except for assembly. Something I have no intention of doing.
xboxown is offline  
Old 07 June 2017, 21:44   #18
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 46
Posts: 359
lol. ok.
alkis is offline  
Old 07 June 2017, 22:14   #19
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,055
@xboxown

Right, I'm home now and have access to my Amigas (and WinUAE, which unfortunately I'm not allowed to use in the office ). The others have covered how to save as ASCII already

Thanks Akira for the translation!

Now, let's just relax a little and have a look at what's going on here. I know it can be frustrating, but it's more a case of getting

You're very close to having it working, but there are a couple of key things to bear in mind. First, the Select...Case setup doesn't work the way you expect when using the AND because the Case keyword expects a single value that is compared to the variable used with the Select command. The reason you didn't get an error here is that when you use AND, Blitz first evaluates what you're ANDing together and then produces a result which is used by the Case keyword. That result will either be True (which is the same thing as -1), or false (which is the same thing as 0). The Case then compares the -1 or 0 to the variable and acts on the result. Note that this behaviour is not Blitz-specific - some simpler BASICs don't support it, but you'll have similar problems doing the same thing with the switch statement in C on any platform for example.

Next, I'm wondering if you intended to use GameB() at all? That's for reading a CD32 pad, but you're only ever checking for the yellow button. If you don't need more than two or three buttons, you should just use Joyb() instead, which reads standard joysticks. Switching to Joyb() and checking for 1 (fire) lets the menu more or less work using a standard joystick. The next issue is that it runs way too fast with your setup - once the fire button or a direction is chosen, every frame it will change the option or chosen menu item. You should add some sort of delay after selection, or some code that means you have to release the stick or button before making another selection, otherwise you need to be able to release the stick or button accurately to 1/60th of a second to select the desired option.

Next, the jumping around isn't making any sort of sense, so your main loop is part of a subroutine that never returns. Some planning will help here, and for simple projects, have a main loop that's the root of your program (your main menu), and jump out to subroutines for extra parts so you always return to your main loop and don't have to add core functionality to your subroutines. Draw a flowchart before you jump into writing the code first.

These aren't really anything to do with Blitz at all and are more conceptual issues. I'll have a look at rearranging your code now and get back to you shortly - I think you're just getting yourself muddled up with no clear idea of where you want to go, which is why a flowchart always helps.

If it's any consolation, I think Blitz is perhaps one of the best languages for writing this sort of thing on the Amiga
Daedalus is offline  
Old 07 June 2017, 22:29   #20
xboxown
Registered User
 
Join Date: Dec 2012
Location: Vancouver/Canada
Posts: 167
@Daedalus

Your on!! * slaps your hand * I will use the delay_ to slow things down. I will do a complete flow chart and paste it here (scan it) and see what you guys think. This project s more about teaching me to proper coding and system analyst than the actual project and learn blitz basic properly and get rid of all the "spinning wheels" and not know from right to left out of the way. Thank you Daedalus for your patience and helping me out.
xboxown is offline  
AdSense AdSense  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[blitz basic] How much amiga-blitz friendly is this? saimon69 Coders. Blitz Basic 104 29 November 2016 20:45
Blitz basic 2 Help Havie Coders. Blitz Basic 30 08 September 2013 09:15
blitz basic petza request.Apps 11 08 April 2007 01:49
Blitz Basic 2 anyone? jobro request.Apps 12 28 November 2005 18:15
Blitz Basic 2 LaundroMat Retrogaming General Discussion 5 24 July 2001 08:10

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 22:31.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.34733 seconds with 13 queries