Forum - MCS Electronics
View previous topic :: View next topic
Author
Message
astroschmidt Joined: 04 Sep 2010 Posts: 33
Posted: Thu Jan 30, 2014 12:28 pm Post subject: Question to the use of SELECT-CASE with multiple statements
Hi folks,
I have a question concerning the correct use of the SELECT-CASE function.
Because according to the help-file of BASCOM one can use several statements after the CASE, I first tried it this way:
Code:
$regfile = "m32def.dat" 'ATMEGA32: 32k Flash, 2k RAM, 1k EEPROM
$framesize = 200
$swstack = 200
$hwstack = 200
$crystal = 16000000 '16 MHz Quarz
Dim Device_mode As Byte
Dim Ist_wert As Single , U_meas As Single , R_meas As Single , P_meas As Single , Last_value_high As Single
Select Case Device_mode
Case 4 : Ist_wert = U_meas : Last_value_high = U_meas
Case 5 : Ist_wert = P_meas : Last_value_high = P_meas
Case 6 : Ist_wert = R_meas : Last_value_high = R_meas
End Select
End
But this gives a compile error.
When I try it the CASE-statements in the following way, I get no compile errors:
Code:
Select Case Device_mode
Case 4
Ist_wert = U_meas : Last_value_high = U_meas
Case 5
Ist_wert = P_meas : Last_value_high = P_meas
Case 6
Ist_wert = R_meas : Last_value_high = R_meas
End Select
So am I right to assume, that multiple statements after a CASE only work, when I write them in a new line?
(Like the "IF-THEN-ELSE-ENDIF" short and long version)
Kind regards
Roger
(BASCOM-AVR version : 2.0.7.6 )
Back to top
albertsm Joined: 09 Apr 2004 Posts: 5913 Location: Holland
Posted: Thu Jan 30, 2014 1:48 pm Post subject:
yes you are right. officially you should be able to use the first syntax. i will have a look at it. _________________ Mark
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum