[ok] Sub Xray(ObjX As Variant) BASIC Argument nicht optional

Programmierung unter AOO/LO (StarBasic, Python, Java, ...)

Moderator: Moderatoren

hfr
**
Beiträge: 37
Registriert: Mo, 09.07.2007 14:42
Wohnort: München

[ok] Sub Xray(ObjX As Variant) BASIC Argument nicht optional

Beitrag von hfr »

Wer hat mit Xray unter OO Basic folgende Erfahrung gemacht und könnte mir helfen?

Ich habe einen Text markiert und ein Beispiel-Makro

Code: Alles auswählen

sub PropertiesEigenschaften
' 2009-07-09 hfr: siehe auch Properties-Abschnitt  in "http://wiki.services.openoffice.org/wiki/DE/Makro_Basic_Tutorial#Eingeben_von_Programm-Code"
' basicLibraries.loadLibrary("Xray") 'wird schon automatisch mit dem Start von Openoffice geladen (meine Einstellungen)
	if fnWhichComponent(thisComponent) = "Text" then

		oCurSelection = thisComponent.getCurrentSelection()

		if oCurSelection.supportsService("com.sun.star.text.TextRanges") then

			nCount = oCurSelection.Count
			
			xray.xray oCurSelection.getByIndex(0)
			
			'Warnung: Am Einfügepunkt wird die selbe Aktion zwei mal angewandt -
			'das macht in diesem Fall nichts, kann aber durchaus problematisch werden.
			for i = 0 to nCount - 1 'Steht i für optionale Mehrfachauswahlen?
				oCurSelection.getByIndex(i).setPropertyValue("CharStyleName", "Strong Emphasis")
				'NUR in OpenOffice.org Basic könne man die Zuweisung auch abkürzen:
				'oCurSelection(i).CharStyleName = "Strong Emphasis"
			next
			
		end if
	end if
end sub 'PropertiesEigenschaften
aufgerufen, das einen Xray -Aufruf beinhaltet.

In der Sub

Code: Alles auswählen

Sub Xray(ObjX As Variant)
Dim kt As Object, isCompatibilityModeTrue As Boolean

' protect from CompatibilityMode(True) current and future incompatibilities
isCompatibilityModeTrue = True
On Error Resume Next
isCompatibilityModeTrue = testPrivateAccess  ' variable testPrivateAccess is in Module Mod2
On Error GoTo 0
if isCompatibilityModeTrue  then  CompatibilityMode(False)

prepareXray
CreateGetObjFunction("") ' init
if IsRealObject(ObjX, false)  then
  Set OriginalObj = ObjX
  if initXrayDisplay(ObjX, txt0113, true)  then
    kt = XrDial.getControl("OriginName")
    kt.Text = txt0115
    On Error Resume Next
    kt.Text =OriginalObj.ImplementationName
    On Error Goto 0
    XrDial.Execute
    XrDial.Dispose
  end if
end if
' restore initial CompatibilityMode() if needed
if isCompatibilityModeTrue  then  CompatibilityMode(True)
End Sub
kommt bei der Zeile

Code: Alles auswählen

if IsRealObject(ObjX, false)  then
eine Fahrermeldung :
OpenOffice.org 3.1
BASIC-Laufzeitfehler.
Argument ist nicht optional
(für engl.Volltext- Sucher:
In the "Sub Xray(ObjX As Variant)", the line "if IsRealObject(ObjX, false) then" generated the runtime error "argument is not optional.")


Weiß jemand, was Ursache und Abhilfe sein könnten? :?

PS: Mein Konfiguration siehe: http://wiki.ubuntuusers.de/Benutzer/Hfr
Zuletzt geändert von hfr am Do, 09.07.2009 21:34, insgesamt 1-mal geändert.
Benutzeravatar
komma4
********
Beiträge: 5332
Registriert: Mi, 03.05.2006 23:29
Wohnort: Chon Buri Thailand Asia
Kontaktdaten:

Re: Sub Xray(ObjX As Variant) BASIC Argument nicht optional ???

Beitrag von komma4 »

Die Fehlermeldung kommt bei Xray, wenn kein Objekt übergeben wurde.


Dein Code läuft bei mir (3.0.1) ohne Probleme, wenn ich -wie gewohnt- auch nur xray objekt angebe (nicht: xray.xray !)
Cheers
Winfried
aktuell: LO 5.3.5.2 30m0(Build:2) SUSE rpm, unter Linux openSuSE Leap 42.3 x86_64/KDE5
DateTime2 Einfügen von Datum/Zeit/Zeitstempel (als OOo Extension)
hfr
**
Beiträge: 37
Registriert: Mo, 09.07.2007 14:42
Wohnort: München

Re: Sub Xray(ObjX As Variant) BASIC Argument nicht optional ???

Beitrag von hfr »

Danke, das war es wohl :)
Antworten