Hallo,
ich habe gerade ein Programm mit mehreren IF-THEN-ELSE-Bedingungen geschrieben.
Das Programm ist für eine Steuerung, mit der ich mehrere Relais, zwei PCs usw. schalten will
Dies geschieht entweder mit der Fernbedienung (RC5) oder mit einem Bedienkästchen mit 12 Tastern. In diesem Kästchen ist auch ein AVR, der den Tastendruck als 4Bit ausgibt und auch 12 LEDs ansteuert, wenn das Signal 4Bit +1Bit ON/OFF kommt.
Beim Kompilieren bringt er die Fehlermeldung:
Error:7 Line: 0 IF THEN expected [ 258] ,in File:
Error:123 Line: 0 END IF expected ,in File:
Ich habe Bascom neu gestartet, vorher brachte er diese Fehlermeldungen mit Zeilenangaben, dort war aber alles 100%ig in Ordnung, weil an dieser Stelle der Syntax genauso war wie weiter oben.
Was kann das sein?
Hier noch mein Code (Achtung, ziemlich umfangreich):
MfG, DaneCode:'Belegung: 'PortA: $regfile = "m32def.dat" $crystal = 12000000 Enable Interrupts Ddra = &B11111111 '0=Eingang 1=Ausgang Ddrb = &B11111111 Ddrc = &B00000000 Ddrd = &B11110000 Porta = &B00000000 Portb = &B00000000 '1=Pull Up Portc = &B00010000 Portd = &B00001111 Dim Address As Byte , Command As Byte , Signal As Byte Dim Bereit As Bit , Bit1 As Bit , Bit2 As Bit , Bit3 As Bit , Bit4 As Bit , Merker1 As Bit Config Rc5 = Pinb.4 'IR-Empfänger sitzt auf PB4 Bereit = 1 'Bereitschaft herstellen Do Getrc5(address , Command) 'IR-Empfänger abfragen Signal = Pind And &B00001111 'Nur die ersten 4 Bits in Variable Signal übernehmen If Bereit = 1 Then 'Ausgabe der Bereitschafts-Variable an eine LED Portd.5 = 1 Else Portd.5 = 0 End If If Address < 255 Or Signal > 0 And Address = 55 Then 'wenn ein Signal von der Fernbedienung oder von PD0 bis PD3 kommt Command = Command And &B01111111 'Toggle Bit entfernen If Command = 1 And Bereit = 1 Or Signal = 1 And Bereit = 1 Then 'Taster 1 Stromstoßrelais Zimmerlicht Portb.0 = 1 Bereit = 0 Waitms 200 Portb.0 = 0 Elseif Command = 2 And Bereit = 1 Or Signal = 2 And Bereit = 1 Then 'Taster 2 Flutlicht Toggle Porta.0 Bereit = 0 Bit1 = 0 Bit2 = 1 Bit3 = 0 Bit4 = 0 If Porta.0 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If Elseif Command = 3 And Bereit = 1 Or Signal = 3 And Bereit = 1 Then 'Taster 3 Schwarzlicht Toggle Porta.1 Bereit = 0 Bit1 = 1 Bit2 = 1 Bit3 = 0 Bit4 = 0 If Porta.1 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If Elseif Command = 4 And Bereit = 1 Or Signal = 4 And Bereit = 1 Then 'Taster 4 Strahler für Spiegelkugel Toggle Portb.1 Bereit = 0 Bit1 = 0 Bit2 = 0 Bit3 = 1 Bit4 = 0 If Portb.1 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If Elseif Command = 5 And Bereit = 1 Or Signal = 5 And Bereit = 1 Then 'Taster 5 Spiegelkugelmotor Toggle Porta.2 Bereit = 0 Bit1 = 1 Bit2 = 0 Bit3 = 1 Bit4 = 0 If Porta.2 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If Elseif Command = 6 And Bereit = 1 Or Signal = 6 And Bereit = 1 Then 'Taster 6 UFO Toggle Portb.2 Bereit = 0 Bit1 = 0 Bit2 = 1 Bit3 = 1 Bit4 = 0 If Portb.2 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If Elseif Command = 7 And Bereit = 1 Or Signal = 7 And Bereit = 1 Then 'Taster 7 Lichterorgel Toggle Porta.3 Bereit = 0 Bit1 = 1 Bit2 = 1 Bit3 = 1 Bit4 = 0 If Porta.3 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If ' Schaltmodul Elseif Command = 8 And Bereit = 1 And Pinc.7 = 0 Or Signal = 8 And Bereit = 1 And Pinc.7 = 0 Then 'Taster 8 Röhrenverst., Mediastation usw. EIN Bereit = 0 Portb.5 = 1 Bit1 = 0 Bit2 = 0 Bit3 = 0 Bit4 = 1 Gosub Ausgeben_ein Waitms 500 Portb.5 = 0 ' Schaltmodul Mediastation Elseif Command = 8 And Bereit = 1 And Pinc.7 = 1 And Pinc.5 = 0 And Pinc.7 = 1 Or Signal = 8 And Bereit = 1 And Pinc.7 = 1 And Pinc.5 = 0 Then 'Taster 8 Röhrenverst., Mediastation usw. AUS, wenn Mediastation nicht läuft Bereit = 0 Portb.6 = 1 Bit1 = 0 Bit2 = 0 Bit3 = 0 Bit4 = 1 Gosub Ausgeben_aus Waitms 500 Portb.6 = 0 Elseif Command = 8 And Bereit = 1 And Portb.5 = 1 And Pinc.5 = 1 Or Signal = 8 And Bereit = 1 And Portb.5 = 1 And Pinc.5 = 1 Then 'Taster 8 Röhrenverst., Mediastation usw. AUS, wenn Mediastation läuft Merker1 = 1 Bereit = 0 Portb.7 = 1 'Taster an Mediastation simulieren Waitms 100 'Taster an Mediastation simulieren Portb.7 = 0 'Taster an Mediastation simulieren Elseif Command = 9 And Bereit = 1 And Pinc.6 = 0 Or Signal = 9 And Bereit = 1 And Pinc.6 = 0 Then 'Taster 9 PC EIN Porta.4 = 1 Bereit = 0 Bit1 = 1 Bit2 = 0 Bit3 = 0 Bit4 = 1 Gosub Ausgeben_ein Elseif Command = 9 And Bereit = 1 And Pinc.6 = 1 Or Signal = 9 And Bereit = 1 And Pinc.6 = 1 Then 'Taster 9 PC AUS Porta.4 = 1 Bereit = 0 Bit1 = 1 Bit2 = 0 Bit3 = 0 Bit4 = 1 Gosub Ausgeben_ein Elseif Command = 10 And Bereit = 1 Or Signal = 10 And Bereit = 1 Then 'Taster 10 Arbeitssteckdose Toggle Porta.5 Bereit = 0 Bit1 = 0 Bit2 = 1 Bit3 = 0 Bit4 = 1 If Porta.5 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If Elseif Command = 11 And Bereit = 1 Or Signal = 11 And Bereit = 1 Then 'Taster 11 Reserve Toggle Porta.6 Bereit = 0 Bit1 = 1 Bit2 = 1 Bit3 = 0 Bit4 = 1 If Porta.6 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If Elseif Command = 12 And Bereit = 1 Or Signal = 12 And Bereit = 1 Then 'Taster 12 Reserve Toggle Portb.4 Bereit = 0 Bit1 = 0 Bit2 = 1 Bit3 = 0 Bit4 = 1 If Portb.4 = 1 Then Gosub Ausgeben_ein Else Gosub Ausgeben_aus End If End If Else Bereit = 1 'wenn kein Signal kommt, dann Bereitschaft wieder herstellen If Merker1 = 1 And Pinc.5 = 0 Then 'wenn Merker gesetzt wurde und Mediastation sich ausgeschaltet hat, Relais auschalten Merker1 = 0 Portb.6 = 1 Bit1 = 0 Bit2 = 0 Bit3 = 0 Bit4 = 1 Gosub Ausgeben_aus Waitms 500 Portb.6 = 0 End If Loop Ausgeben_ein: Portd.4 = 1 'Bit ON/OFF Portd.0 = Bit1 Portd.1 = Bit2 Portd.2 = Bit3 Portd.3 = Bit4 Waitms 500 Portd.0 = 0 Portd.1 = 0 Portd.2 = 0 Portd.3 = 0 Portd.4 = 0 Return Ausgeben_aus: Portd.4 = 0 'Bit ON/OFF Portd.0 = Bit1 Portd.1 = Bit2 Portd.2 = Bit3 Portd.3 = Bit4 Waitms 500 Portd.0 = 0 Portd.1 = 0 Portd.2 = 0 Portd.3 = 0 Portd.4 = 0 Return End







Zitieren
Lesezeichen