syntax error on select case

Simontelescopium

Member
Licensed User
Hi
I have what appears to be an intermittent problem...

I have the code
B4X:
Sub testtarget(destruction)

f = attacktarget.targetno
Msgbox(attacktarget.targettype&f)
test = attacktarget.targettype
Select test
Case "pirates"
   If pirates(f).shield<destruction Then 'destruction overwhelms shield       destruction = destruction -pirates(f).shield
      pirates(f).shield=0
      If pirates(f).hull<destruction Then ' it's a kill          'destruction = destruction -pirates(f).hull
         pirates(f).hull=0
         pirates(f).target=0
         pirates(f).show=0
         destroyedship(0) ' ship destroyed, decide what to do.
      Else ' just damage hull
         pirates(f).hull=pirates(f).hull-destruction
         'destruction=0
                   Exit 
      End If   
   Else ' shield greater than destruction
      pirates(f).shield=pirates(f).shield-destruction
      destruction=0
   End If
   
   Case "traders"
'to do
   Case "police"
'to do
   Case Else
   Msgbox("else")
   End Select
'End If 
End Sub

when I run my program this seems to work fine but ocassionally i get a run time error

An error occurred on sub main.testtarget
Line Number:2695 (this is teh line with Select Test on it)
Select Test
Error description
Syntax error.
Continue?


The program will run through this routine fine many times with test="pirates" when the error occurs test="pirates" also

Any ideas what I am doing wrong to cause a syntax error?
 

agraham

Expert
Licensed User
Longtime User
It's possibly the use of the Exit keyword where it is not valid, it is only for use in exiting a loop so it may be upsetting one of the the IDE interpreters internal stacks. If you try to compile your program you will probably get a "CS0139 - No enclosing loop ..." external compiler error. When faced with strange bugs it is always a good idea to compile it to see if it compiles OK as the IDE can ignore some problems that the stricter compiler will point out.
 

Simontelescopium

Member
Licensed User
Ah, of course, thanks, works now!
An error that says Exit with no enclosing loop would be nice!
What has happened here is I got focused on the select command so missed my other errors.
 

moster67

Expert
Licensed User
Longtime User
Agraham, please stop it!

This is the 3rd or 4th time in recent times you are picking on Sitajony in public. If you have something to tell him, please send him a PM and do it privately.

I don't like seeing these rather aggressive remarks in public.

:sign0161: Why do you keep cluttering the forum by posting the obvious?
 

sitajony

Active Member
Licensed User
I wanted just say he can use this keyword, in thinking that it didn't know how exit the sub function without use "Exit"...
I'll wait the question for give an answer the next time...
Sorry
 

taximania

Well-Known Member
Licensed User
Longtime User
@sitajony Your enthusiasm for B4ppc is appreciated on the forum
Many of your post's are a bit pointless though. Sorry

@moster67 AGraham is/was a MAJOR contributer to the Basic4ppc community.
He only said, what I thought. :-(

This forum has no moderators. Apart from Erel.
If a post is made that other people don't like,
it usually sorts itself out.

I hope AGraham continues to visit the forum.
But I fear, the forum has just lost one of it's best members.

@Agraham: Email me please. It's on my website
 

sitajony

Active Member
Licensed User
But why he left? I wanted just help but I didn't know that it was not usefull... If he want no more see me on this forum I can stop to write i don't want he left, he's too usefull for every forum members...
I thought he wanted just say this to moster67 in joking but not to himself
@agraham: I can stop to write on this forum if you want, excuse me...
In fact I like speak/help every people it's normal if sometime I say some stuff no usefull...

I hope that you'll come back very soon
 

mjcoon

Well-Known Member
Licensed User
I am sympathetic to, and in partial agreement with, all the views that have been expressed recently in this thread.

Perhaps we can all improve our behaviour and tolerance just enough to return to the mutual assistance that makes this forum such a valuable resource.

Mike.
 

moster67

Expert
Licensed User
Longtime User
I did indeed receive a nice reply from Agraham and with that said, I fully agree with what Agraham just said to forget about it and let us all go on.

Relax guys, and thanks for the emails. I have received a gracious email from moster67 to which I have of course replied in the same vein. Let's forget it now shall we - I will.
 

Cableguy

Expert
Licensed User
Longtime User
Sorry, but I just noticed this thread's direction just now, and was very surprised...

As Taximania stated, we never had nor needed a moderator, as the purpose of this forum has always been to help those in need..

Moster67, I agree that, when one of us does not see eye-to-eye with someone, that we should set our diferences in private, but I also think that a slap in the hand should also be given in private.

Agraham is a major contributor for this forum, and his work is very apreciated...but sometimes he can be somewhat pedantic, in its own words...

We must not see any less positive remark in this forum as a depreciative personal remark...
If any of us would just flee because of a negative post, the forum would have died a long time ago.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…