Funny compile error using select case statement

I am using Xojo to amend my previously working RealStudio app. Now I get a funny error when trying to compile the app, as follows.

I have a ContextualMenuAction handler that starts:

dim selectedText as string
selectedText = transcriptionText.Seltext
dim ss as string
ss = hititem.text

Select Case ss

When I compile the app, I get the error message

TLSTranscription.transcriptionText.ContextualMenuAction, line 6 Type mismatch error. Expected String but got Int32
Select Case Case ss

The Case Case is not a typo, it is what is being displayed in the Errors pane.

I have tried deleting the Select Case statement, saving the project and then reinserting it to no avail, the compile still fails the same way.

Anyone see this before?

bobj

Can you post the rest of the Select statement?

Andrew

here it is. Following your reply, I reviewed the complete statement again and noticed that from case 17 onwards, I had not yet replaced the number, ie 18, by the text, ie Unhilite All. Having fixed that, it now compiles. So the issues seems to be mixed types of case expressions, ie. text and integer, which have caused the compiler to seemingly spit the dummy.

Thanks though, your request made me look at things in a new light.

bobj

dim selectedText as string
selectedText = transcriptionText.Seltext
dim ss as string
ss = hititem.text

select case ss
case “Timecode markup”
doTimecodemarkup true
case “Normal editing”
doNormalediting true
case “Find/Replace”
FindReplaceWindow.show
case “-”
// separator
case “Play/Stop”
doPlaystop false
case “Start movie at time”
if str(val(selectedText)) = selectedText then
elapsedTime.text = selectedText
doPlaystop true
else
msgbox “Error, you must select a timecode value first”
end if
case “Insert newline”
if not transcriptionText.readonly then
transcriptionText.selText = App.CRLF
end if
case “Insert newline with markup”
if not transcriptionText.readonly then
insertparamarkup true
end if
case “Check paragraph lengths”
checkParagraphLengths
case “Topic - add to People”
addTopic(“People”,selectedText)
case “Topic - add to Places”
addTopic(“Places”,selectedText)
case “Topic - add to Organisations”
addTopic(“Organisations”,selectedText)
case “Topic - add to Exhibitions”
addTopic(“Exhibitions”,selectedText)
case 17
// separator
case 18 //Unhilite All
transcriptionText.SelStart = 0
transcriptionText.SelLength = transcriptionText.text.Len
transcriptionText.SelTextColor = RGB(0,0,0)
transcriptionText.SelLength = 0
case 19 //Zoom In
transcriptionText.textSize = transcriptionText.textSize * 1.5
case 20 // Zoom Out
transcriptionText.textSize = transcriptionText.textSize / 1.5
case 16 //Lock/Unlock transcript
transcriptionText.readOnly = not(transcriptionText.readOnly)
end select

Right, Xojo is strongly typed so the expression for each Case statement must evaluate to the same type as the Select expression.

Thanks for this solution: I was stuck on the same issue - I think in this case (sorry) it’s years of looking at the line in error rather than what the compiler is trying to do… Possibly worth amending the error message (by adding ‘in a following case statement’) if that’s possible?

You should file a bug report asking that the error message be improved.