ubuntuusers.de

Rätselhaftes StarBasic

Status: Ungelöst | Ubuntu-Version: Ubuntu 24.04 (Noble Numbat)
Antworten |

Friedrich-Gille

Anmeldungsdatum:
20. Januar 2016

Beiträge: 29

Hallo, ich nutze auf einem PC Libre Offic und auf einem anderen OpenOffice. Für beide Calc habe ich Star Basic Programme in Anwendung. In LibreOffic laufen die StarBasic Scrips nicht. Es kommt die Fehlermeldung "Syntax Fehler erwarte Sub" sowohl Sub als auch End Sub sind aber vorhanden. Zur Zeit bin ich ratlos was da helfen könnte. ich hoffe auf Eure Meinungen oder Beträge Gruß Friedrich

Marc_BlackJack_Rintsch Team-Icon

Ehemalige
Avatar von Marc_BlackJack_Rintsch

Anmeldungsdatum:
16. Juni 2006

Beiträge: 4681

Wohnort: Berlin

Wo kommt die Fehlermeldung und die müsste doch eigentlich noch genauer auf die Stelle im Quelltext hinweisen wo der Fehler bemerkt wurde.

Das irgendwo Sub und End Sub stehen, heisst ja nicht, dass sie an der Stelle stehen wo der Compiler sie erwartet.

micneu

Avatar von micneu

Anmeldungsdatum:
19. Januar 2021

Beiträge: 777

Wohnort: Hamburg

Frage gehört StarBasic zu Shell Programierug? Ich denke mit deinem Problem bist du im Libre/OpenOdffice Forum besser aufgehoben den nach meinem Empfinden hat es doch nichts mit Ubuntu zu tun?

Friedrich-Gille

(Themenstarter)

Anmeldungsdatum:
20. Januar 2016

Beiträge: 29

Marc_BlackJack_Rintsch schrieb:

Wo kommt die Fehlermeldung und die müsste doch eigentlich noch genauer auf die Stelle im Quelltext hinweisen wo der Fehler bemerkt wurde.

Das irgendwo Sub und End Sub stehen, heisst ja nicht, dass sie an der Stelle stehen wo der Compiler sie erwartet.

Die Fehlermeldung erfolgt genau in der letzten Zeile in der End Sub steht

Friedrich-Gille

(Themenstarter)

Anmeldungsdatum:
20. Januar 2016

Beiträge: 29

micneu schrieb:

Frage gehört StarBasic zu Shell Programierug? Ich denke mit deinem Problem bist du im Libre/OpenOdffice Forum besser aufgehoben den nach meinem Empfinden hat es doch nichts mit Ubuntu zu tun?

Ja schon, aber beide Progs unterstützen doch StarBasic. Und kurios : Erst beim Script- Aufruf kommt der Fehler.

NORACSA

Anmeldungsdatum:
31. Januar 2010

Beiträge: 182

micneu schrieb:

Frage gehört StarBasic zu Shell Programierug?

Dieses Unterforum heißt "Shell und Programmieren", nicht "Shell Programmieren".

micneu

Avatar von micneu

Anmeldungsdatum:
19. Januar 2021

Beiträge: 777

Wohnort: Hamburg

Das ist richtig aber ubuntu und nicht StarBasic. Shell, Python, awk usw. Ist nach meinem Empfinden hier richtig, StarBasic ist in einem Programm und nicht im Betriebssysteme

verdooft

Anmeldungsdatum:
15. September 2012

Beiträge: 4414

Wobei LibreOffice schon zu Ubuntu gehört, im Thread, welche Themen hier her gehören, steht:

Dieser Bereich des Forums befaßt sich mit Programmiersprachen unter Linux...

StarBasic von LibreOffice unter Linux, sogar Ubuntu.

Friedrich-Gille schrieb:

In LibreOffic laufen die StarBasic Scrips nicht. Es kommt die Fehlermeldung "Syntax Fehler erwarte Sub" sowohl Sub als auch End Sub sind aber vorhanden. Zur Zeit bin ich ratlos was da helfen könnte.

Kannst du das auf ein kurzes Beispiel runterbrechen und hier posten?

Friedrich-Gille

(Themenstarter)

Anmeldungsdatum:
20. Januar 2016

Beiträge: 29

verdooft schrieb:

Wobei LibreOffice schon zu Ubuntu gehört, im Thread, welche Themen hier her gehören, steht:

Dieser Bereich des Forums befaßt sich mit Programmiersprachen unter Linux...

StarBasic von LibreOffice unter Linux, sogar Ubuntu.

Friedrich-Gille schrieb:

In LibreOffic laufen die StarBasic Scrips nicht. Es kommt die Fehlermeldung "Syntax Fehler erwarte Sub" sowohl Sub als auch End Sub sind aber vorhanden. Zur Zeit bin ich ratlos was da helfen könnte.

Kannst du das auf ein kurzes Beispiel runterbrechen und hier posten?

Anbei der Teil an dem am Ende die Fehlermeldung kommt. Dieser Abschnitt ist als Aufzeichnung übernommen. Davor gibt es in noch mehrere Sub und End Sub, die scheinbar nicht betroffen sind.

sub Purge

rem definiere variable
dim document   as object
dim Blatt as object
dim Quad 1 (1 To 9, 1 To 9) As integer
dim Quad 2 (1 To 9, 11 To 19) As integer
dim Quad 3 ( 11 To 19, To 1 To 9) As integer 

rem Zugriff auf dieses Document
Doc  = ThisComponent
rem Zugriff auf dieses Blatt
Blatt = Dok.Sheets.getByName ("Tabelle2")
rem Zugriff auf Quadratm Array 1

dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$B$2:$J$10"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$L$2:$T$10"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$B$12:$J$20"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())

end sub

Hier erscheint erst die Meldung

Bearbeitet von rklm:

Codeblock

Marc_BlackJack_Rintsch Team-Icon

Ehemalige
Avatar von Marc_BlackJack_Rintsch

Anmeldungsdatum:
16. Juni 2006

Beiträge: 4681

Wohnort: Berlin

@Friedrich-Gille: Quelltext bitte als Codeblock, sonst ist das im Beitrag nicht wirklich lesbar. Und dann auch den tatsächlichen Quelltext. Der hier bleibt erst bei DIM-Anweisungen hängen wo Leerzeichen in Namen sind, dann ist bei einem DIM ein To zu viel, dann wird Doc deklariert/definiert aber versucht auf Dok zuzugreifen, und an der Stelle hatte ich dann keine Lust mehr mich da zeilenweise durch die Fehler zu fixen wenn das überhaupt nicht der Code ist, um den es tatsächlich geht.

TomTobin

Avatar von TomTobin

Anmeldungsdatum:
24. August 2007

Beiträge: 3101

Davor gibt es in noch mehrere Sub und End Sub, die scheinbar nicht betroffen sind.

Deswegen müsstest Du auch das komplette Skript posten. Da ein sub xyz weiter oben ohne end sub weiter unten durchaus auch den Fehler verursachen kann.

rklm Team-Icon

Projektleitung

Anmeldungsdatum:
16. Oktober 2011

Beiträge: 13192

TomTobin schrieb:

Davor gibt es in noch mehrere Sub und End Sub, die scheinbar nicht betroffen sind.

Deswegen müsstest Du auch das komplette Skript posten. Da ein sub xyz weiter oben ohne end sub weiter unten durchaus auch den Fehler verursachen kann.

Ja, das ist auch in der Shell ein typischer Fall: man vergisst irgendwo oben das schließende Anführungszeichen und bekommt dann eine Meldung, dass am Ende etwas nicht stimmt. Ganzes Skript wird auf jeden Fall hilfreich sein.

Friedrich-Gille

(Themenstarter)

Anmeldungsdatum:
20. Januar 2016

Beiträge: 29

EM  *****  BASIC  *****

sub Sudoku1

Rem definire Variable
rem definiere Datei, Tabelle und Zelle
dim Dok as Object
dim Blatt as Object
dim Zelle as Object

Dok = ThisComponent
Blatt = Dok.Sheets.getByName ("Tabelle1")

dim Sp as Integer  rem Spalte des Hauptquadrat
dim Re as Integer  rem Reihe des Hauptquadrat

dim oZelle as Object  rem optionale Zelle im andern Quadrat
dim oSp as Integer    rem optionale Spalte
dim oRe as Integer    rem optionale Reihe

dim pN7 as Integer	rem soll die realen Werte in den anderen Quadraten setzem 
dim pN6 as Integer 	rem dito
dim pN5 as Integer	rem soll die realen Werte in den anderen Quadraten setzem 
dim pN4 as Integer 	rem dito
dim pN3 as Integer 	rem Durchlauf bei "For pN2" setzt pN = 1 und sucht pN neu
dim pN2 as Integer  rem Durchlauf bei "For I" sucht pN "noch nicht belegt"
dim pN as Integer   rem zu prüfender Wert/Zahl sucht nP im Durchlauf bei "For pN"

Sp = 1  rem Spalte B
Re = 1  rem Zeile 2
oSp = 11  rem Spalte L
oRe = 1  rem Zeile 2

Zelle = Blatt.getCellByPosition(Sp,Re)
oZelle = Blatt.getCellByPosition(oSp,oRe)
For pN3 = 1 To 9  
  For pN2 = 1 To 9
    Zelle = Blatt.getCellByPosition(Sp,Re)
    oZelle = Blatt.getCellByPosition(oSp,oRe)
    let pN = 1
    let oSp = 11
    For pN = 1 To 9   
      Zelle = Blatt.getCellByPosition(Sp,Re)
      oZelle = Blatt.getCellByPosition(oSp,oRe)
     If oZelle.Value > 0 Then
        oZelle.Value = oZelle.Value 
     ElseIf Zelle.Value = pN Then   
       oZelle.Value = 99
     Endif        
       oSp = oSp + 1
    Next pN
     let Sp = Sp +1
     let oSp = oSp + 1
  Next pN2
  
  let Sp = 1
  let oSp  = 11
  let Re = Re + 1
  let oRe = oRe + 1
  
Next pN3  

Sp = 1  rem Spalte B
Re = 1  rem Zeile 2
oSp = 1  rem Spalte L
oRe = 11  rem Zeile 2
For pN3 = 1To 9
  
 For pN2 = 1 To 9
   Zelle = Blatt.getCellByPosition(Sp,Re)
   oZelle = Blatt.getCellByPosition(oSp,oRe)
   let pN = 1
   let oRe = 11
    For pN = 1 To 9   
      Zelle = Blatt.getCellByPosition(Sp,Re)
      oZelle = Blatt.getCellByPosition(oSp,oRe)
      If oZelle.Value > 0 Then
        oZelle.Value = oZelle.Value 
      ElseIf Zelle.Value = pN Then   
       oZelle.Value = 99
      Endif        
       oRe = oRe + 1
    Next pN
     let Re = Re +1
     let oRe = oRe + 1
  Next pN2
  
  let Re = 1
  let oRe  = 11
  let Sp = Sp + 1
  let oSp = oSp + 1
  
Next pN3  
 rem die Reihen und Spalten Prüfung 31 bis hier OK,
 rem Aus Modul2 "Probe" kopiert
 rem die Prüfung Reihe plus Spalte noch programieren, wie?   

rem Zelle = Blatt.getCellByPosition(Sp,Re)
'oZelle = Blatt.getCellByPosition(oSp,oRe)
'
'For pN5 = 1 to 9
'
'  oZelle = Blatt.getCellByPosition (oSp,oRe)
'  let pN = 1
'  let oRe = 1
'  let oSp = 11   
'  For pN4 = 1 to 9
'    oZelle = Blatt.getCellByPosition (oSp,oRe)        
'    If oZelle.Value < 9 Then
'       oZelle.Value = pN
'    Endif
'      oSp = oSp + 1
'  Next pN4
'    let oSp = 11
'    let oRe = oRe + 1
'Next pN5
'  
'oSp = 1
'oRe = 11
'
'oZelle = Blatt.getCellByPosition(oSp,oRe)
'
'For pN7 = 1 to 9
'
' oZelle = Blatt.getCellByPosition (oSp,oRe)
'  let pN = 1
'  let oSp = 1
'  let oRe = 11   
'  For pN6 = 1 to 9
'    oZelle = Blatt.getCellByPosition (oSp,oRe)        
'    If oZelle.Value < 9 Then
'       oZelle.Value = pN
'    Endif
'      oRe = oRe + 1
'  Next pN6
'    rem let Sp = Sp +1
'    let oRe = 11
'    let oSp = oSp + 1
'Next pN7   
end sub

REM  *****  BASIC  *****

sub Sudoku2

Rem definire Variable
rem definiere Datei, Tabelle und Zelle
dim Dok as Object
dim Blatt as Object
dim Zelle as Object

Dok = ThisComponent
Blatt = Dok.Sheets.getByName ("Tabelle2")

dim Sp as Integer  rem Spalte des Hauptquadrat
dim Re as Integer  rem Reihe des Hauptquadrat

dim oZelle as Object  rem optionale Zelle im andern Quadrat
dim oSp as Integer    rem optionale Spalte
dim oRe as Integer    rem optionale Reihe

dim pN7 as Integer	rem soll die realen Werte in den anderen Quadraten setzem 
dim pN6 as Integer 	rem dito
dim pN5 as Integer	rem soll die realen Werte in den anderen Quadraten setzem 
dim pN4 as Integer 	rem dito
dim pN3 as Integer 	rem Durchlauf bei "For pN2" setzt pN = 1 und sucht pN neu
dim pN2 as Integer  rem Durchlauf bei "For I" sucht pN "noch nicht belegt"
dim pN as Integer   rem zu prüfender Wert/Zahl sucht nP im Durchlauf bei "For pN"

Sp = 1  rem Spalte B
Re = 1  rem Zeile 2
oSp = 11  rem Spalte L
oRe = 1  rem Zeile 2

Zelle = Blatt.getCellByPosition(Sp,Re)
oZelle = Blatt.getCellByPosition(oSp,oRe)
For pN3 = 1 To 9  
  For pN2 = 1 To 9
    Zelle = Blatt.getCellByPosition(Sp,Re)
    oZelle = Blatt.getCellByPosition(oSp,oRe)
    let pN = 1
    let oSp = 11
    For pN = 1 To 9   
      Zelle = Blatt.getCellByPosition(Sp,Re)
      oZelle = Blatt.getCellByPosition(oSp,oRe)
     If oZelle.Value > 0 Then
        oZelle.Value = oZelle.Value 
     ElseIf Zelle.Value = pN Then   
       oZelle.Value = 99
     Endif        
       oSp = oSp + 1
    Next pN
     let Sp = Sp +1
     let oSp = oSp + 1
  Next pN2
  
  let Sp = 1
  let oSp  = 11
  let Re = Re + 1
  let oRe = oRe + 1
  
Next pN3  

Sp = 1  rem Spalte B
Re = 1  rem Zeile 2
oSp = 1  rem Spalte L
oRe = 11  rem Zeile 2
For pN3 = 1To 9
  
 For pN2 = 1 To 9
   Zelle = Blatt.getCellByPosition(Sp,Re)
   oZelle = Blatt.getCellByPosition(oSp,oRe)
   let pN = 1
   let oRe = 11
    For pN = 1 To 9   
      Zelle = Blatt.getCellByPosition(Sp,Re)
      oZelle = Blatt.getCellByPosition(oSp,oRe)
      If oZelle.Value > 0 Then
        oZelle.Value = oZelle.Value 
      ElseIf Zelle.Value = pN Then   
       oZelle.Value = 99
      Endif        
       oRe = oRe + 1
    Next pN
     let Re = Re +1
     let oRe = oRe + 1
  Next pN2
  
  let Re = 1
  let oRe  = 11
  let Sp = Sp + 1
  let oSp = oSp + 1
  
Next pN3  
 rem die Reihen und Spalten Prüfung 31 bis hier OK,
 rem Aus Modul2 "Probe" kopiert
 rem die Prüfung Reihe plus Spalte noch programieren, wie?   

rem Zelle = Blatt.getCellByPosition(Sp,Re)
'oZelle = Blatt.getCellByPosition(oSp,oRe)
'
'For pN5 = 1 to 9
'
'  oZelle = Blatt.getCellByPosition (oSp,oRe)
'  let pN = 1
'  let oRe = 1
'  let oSp = 11   
'  For pN4 = 1 to 9
'    oZelle = Blatt.getCellByPosition (oSp,oRe)        
'    If oZelle.Value < 9 Then
'       oZelle.Value = pN
'    Endif
'      oSp = oSp + 1
'  Next pN4
'    let oSp = 11
'    let oRe = oRe + 1
'Next pN5
'  
'oSp = 1
'oRe = 11
'
'oZelle = Blatt.getCellByPosition(oSp,oRe)
'
'For pN7 = 1 to 9
'
' oZelle = Blatt.getCellByPosition (oSp,oRe)
'  let pN = 1
'  let oSp = 1
'  let oRe = 11   
'  For pN6 = 1 to 9
'    oZelle = Blatt.getCellByPosition (oSp,oRe)        
'    If oZelle.Value < 9 Then
'       oZelle.Value = pN
'    Endif
'      oRe = oRe + 1
'  Next pN6
'    rem let Sp = Sp +1
'    let oRe = 11
'    let oSp = oSp + 1
'Next pN7   
end sub


sub Moeglich

rem definiere Datei, Tabelle und Zelle
dim Dok as Object
dim Blatt as Object
dim Zelle as Object

Dok = ThisComponent
Blatt = Dok.Sheets.getByName ("Tabelle2")

dim Sp as Integer  rem aktuelle Spalte der Zelle
dim Re as Integer  rem aktuelle Reihe der Zelle

dim prfZell as Object  rem prüfe Zelle in dieser Reihe/Spalte
dim prSp as Integer    rem prüfe Spalte
dim prRe as Integer    rem prüfe Reihe

prfZell = MsgBox (ActiveCell.Address)

byPosition

End Sub

REM  *****  BASIC  *****

Sub Sudoku3

Rem definiere Variable
rem definiere Datei, Tabelle und Zelle
dim Dok as Object
dim Blatt as Object
dim Zelle as Object

Dok = ThisComponent
Blatt = Dok.Sheets.getByName ("Tabelle3")

dim Sp as Integer     rem Spalte des Hauptquadrat
dim Re as Integer     rem Reihe des Hauptquadrat

dim oZelle as Object  rem optionale Zelle im andern Quadrat
dim oSp as Integer    rem optionale Spalte
dim oRe as Integer    rem optionale Reihe

dim pN7 as Integer	rem soll die realen Werte in den anderen Quadraten setzem 
dim pN6 as Integer 	rem dito
dim pN5 as Integer	rem soll die realen Werte in den anderen Quadraten setzem 
dim pN4 as Integer 	rem dito
dim pN3 as Integer 	rem Durchlauf bei "For pN2" setzt pN = 1 und sucht pN neu
dim pN2 as Integer  rem Durchlauf bei "For I" sucht pN "noch nicht belegt"
dim pN as Integer   rem zu prüfender Wert/Zahl sucht nP im Durchlauf bei "For pN"

Sp = 1          rem Spalte B
Re = 1          rem Zeile 2
oSp = 11        rem Spalte L
oRe = 1         rem Zeile 2

Zelle = Blatt.getCellByPosition(Sp,Re)
oZelle = Blatt.getCellByPosition(oSp,oRe)
For pN3 = 1 To 9  
  For pN2 = 1 To 9
    Zelle = Blatt.getCellByPosition(Sp,Re)
    oZelle = Blatt.getCellByPosition(oSp,oRe)
    let pN = 1
    let oSp = 11
    For pN = 1 To 9   
      Zelle = Blatt.getCellByPosition(Sp,Re)
      oZelle = Blatt.getCellByPosition(oSp,oRe)
     If oZelle.Value > 0 Then
        oZelle.Value = oZelle.Value 
     ElseIf Zelle.Value = pN Then   
       oZelle.Value = 99
     Endif        
       oSp = oSp + 1
    Next pN
     let Sp = Sp +1
     let oSp = oSp + 1
  Next pN2
  
  let Sp = 1
  let oSp  = 11
  let Re = Re + 1
  let oRe = oRe + 1
  
Next pN3  

Sp = 1  rem Spalte B
Re = 1  rem Zeile 2
oSp = 1  rem Spalte L
oRe = 11  rem Zeile 2
For pN3 = 1To 9
  
 For pN2 = 1 To 9
   Zelle = Blatt.getCellByPosition(Sp,Re)
   oZelle = Blatt.getCellByPosition(oSp,oRe)
   let pN = 1
   let oRe = 11
    For pN = 1 To 9   
      Zelle = Blatt.getCellByPosition(Sp,Re)
      oZelle = Blatt.getCellByPosition(oSp,oRe)
      If oZelle.Value > 0 Then
        oZelle.Value = oZelle.Value 
      ElseIf Zelle.Value = pN Then   
       oZelle.Value = 99
      Endif        
       oRe = oRe + 1
    Next pN
     let Re = Re +1
     let oRe = oRe + 1
  Next pN2
  
  let Re = 1
  let oRe  = 11
  let Sp = Sp + 1
  let oSp = oSp + 1
  
Next pN3  
  
end sub

rem sub Purge
rem 
rem definiere variable
rem dim document   as object
rem dim Blatt as object
rem dim Quad 1 (1 To 9, 1 To 9) As integer
rem dim Quad 2 (1 To 9, 11 To 19) As integer
rem dim Quad 3 ( 11 To 19, To 1 To 9) As integer 
rem 
rem Zugriff auf dieses Document
rem Doc  = ThisComponent
rem Zugriff auf dieses Blatt
rem Blatt = Dok.Sheets.getByName ("Tabelle2")
rem Zugriff auf Quadratm Array 1
rem 
rem dim args1(0) as new com.sun.star.beans.PropertyValue
rem args1(0).Name = "ToPoint"
rem args1(0).Value = "$B$2:$J$10"
rem 
rem dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem 
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem 
rem ----------------------------------------------------------------------
rem dim args2(0) as new com.sun.star.beans.PropertyValue
rem args2(0).Name = "ToPoint"
rem args2(0).Value = "$L$2:$T$10"
rem 
rem dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem 
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem 
rem ----------------------------------------------------------------------
rem dim args3(0) as new com.sun.star.beans.PropertyValue
rem args3(0).Name = "ToPoint"
rem args3(0).Value = "$B$12:$J$20"
rem 
rem dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem 
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:ClearContents", "", 0, Array())
rem 
rem end sub[mark]Formatierter Text[/mark]

Marc_BlackJack_Rintsch Team-Icon

Ehemalige
Avatar von Marc_BlackJack_Rintsch

Anmeldungsdatum:
16. Juni 2006

Beiträge: 4681

Wohnort: Berlin

@Friedrich-Gille: Bitte einmal ganz am Anfang die erste Zeile korrigieren, denn diese erste Zeile reicht schon aus um diese Fehlermeldung zu bekommen.

Edit: Ich würde übrigens dringend empfehlen auch den Inhalt von Unterroutinen einzurücken, denn spätestens wenn man mehr als eine Unterroutine im Modul hat, kann das unübersichtlich werden wo welche anfängt und aufhört.

Antworten |