openoffice-users-de mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wolfgang Jäth <jawo.ml.hams...@arcor.de>
Subject Re: [Basic] Laufzeitfehler "Objektvariable nicht belegt"
Date Mon, 29 Jun 2020 14:59:01 GMT
Am 29.06.2020 um 13:38 schrieb Jörg Schmidt:
>> Und was ich da angegeben habe, *ist* der relevante Code. 
> 
> Tut mir leid, aber das kann nicht stimmen, weil z.B. Schleifen fehlen, Variablen-Inhalte
fehlen (z.B. kann niemand errarten was der Inhalt von "WMOutput" ist /wenn es eine Variable
ist, ist kein Inhalt angegeben, wenn es der Name eines benannten Bereiches wäre, fehlen die
"") und weil es auch nicht stimmen kann das: "Aber gut, kleiner Test, direkt davor folgende
Zeilen eingefügt:", denn das hiesse ja der Inhalt für aMatrix würde zugewiesen bevor aMatrix
deklariert wird.

AMatrix wird in anderen Funktionen zusammengestellt und soll hier
ausgegeben werden. Aber wenn du mir nicht glaubst, dass der Code "drum herum" 
dir nicht weiter helfen wird, bitte (inklusive dem notwendigsten *zu* dem 
"drum rum"; wie ich schon schrub, steht /viel/ irrelevantes dazwischen):

Const SDValueMin As Integer = 1
Const SDValueMax As Integer = 9
Const SDVCheckMin As Integer = 0
Const SDVCheckMax As Integer = 15
Const SDDataMin As Integer = 0
Const SDDataMax As Integer = 5
Const SDMatrix As Integer = 1
Const SDRanges As Integer = 2
Const SDScopes As Integer = 3
Const SDValue As Integer = 4
Const SDNumbers As Integer = 5
Const SDMaxLoops As Integer = 9
'	:	:	:
'	:	:	:
Const SDLog As String = "X1"
Const IsLog As Integer = 1
Dim sLogFile As String


Sub Calculate
'==============
	Dim myData (SDMatrix To SDScopes) As Variant
	Dim currLoop, myAlterations As Integer
	
	Clear
	
	ShowStep ("0.InitRanges")
	myData (SDRanges) = InitRanges
	
	ShowStep ("0.InitScopes")
	myData (SDScopes)  = InitScopes
	
	ShowStep ("0.ReadMatrix")
	myData (SDMatrix) = ReadMatrix
	
	ShowStep ("0.Numbers")
	CheckNumbers (myData)
	
	sLogFile = ""
	currLoop = SDMaxLoops
	Do
		currLoop = currLoop - 1

		ShowStep (SDMaxLoops-currLoop & ".Singles")
		myAlterations = CheckSingles (myData)

		ShowStep (SDMaxLoops-currLoop & ".Triples")
		myAlterations = myAlterations + CheckTriplets (myData)

		ShowStep (SDMaxLoops-currLoop & ".Options")
		myAlterations = myAlterations + CheckOptions (myData)

		ShowStep (SDMaxLoops-currLoop & ".UpsideDown")
		myAlterations = myAlterations + CheckUpsides (myData)
	Loop Until (myAlterations <= 0) OR (currLoop <= 0)

	Verify (myData)
	
	WriteMatrix (myData (SDMatrix))
End Sub


Sub WriteMatrix (aMatrix As Variant)
	Const WMOutput As String = "K1:S9"
	Const WMCheckpoints As String = "AA1:AP9"
	Dim currRow, currCol, myDigits As Integer
	Dim aOutput, myValue As Variant
	Dim oSheet, oOutput As Object
	oSheet = thisComponent.getCurrentController.getActiveSheet

	If IsLog >= 1 Then
		oSheet.getCellRangeByName (SDLog).String = sLogFile
	End If

	oOutput = oSheet.getCellRangeByName (WMOutput)
	aOutput = oRange.getDataArray()

	For currRow = SDValueMin To SDValueMax
		For currCol = SDValueMin To SDValueMax
			myValue = aMatrix (currRow, currCol, SDValue)
			If myValue > 0 Then
				aOutput (currRow)(currCol) = myValue
			Else
				myDigits = CountBits (aMatrix (currRow, currCol, SDNumbers))
				Select Case myDigits
				Case 1
					aOutput (currRow)(currCol) = Options2Bits (aMatrix (currRow,
currCol, SDNumbers))
				Case 2 To 6
					aOutput (currRow)(currCol) = Options2String (aMatrix (currRow,
currCol, SDNumbers), 6)
				Case Else
					aOutput (currRow)(currCol) = Options2String (aMatrix (currRow,
currCol, SDNumbers), 11)
				End Select
			End If
		Next
		For currCol = SDVCheckMin To SDVCheckMax
			'	:	:	:
			'	:	:	:
		Next
	Next
	oOutput.setDataArray (aOutput)
End Sub


Function ReadMatrix As Variant
	Const RMInput As String = "A1:I9"	
	Dim currRow, currCol As Integer
	Dim aMatrix (SDValueMin To SDValueMax, SDValueMin To SDValueMax,
SDDataMin To SDDataMax) As Integer
	Dim aInput, myValue As Variant
	Dim oSheet, oInput As Object
	oSheet = thisComponent.getCurrentController.getActiveSheet

	oInput = oSheet.getCellRangeByName (RMInput)
	aInput = oInput.getDataArray()
	'	:	:	:
	'	:	:	:
	ReadMatrix = aMatrix
End Function


Function CountBits (iOptions As Integer) As Integer
	Dim currPos, myMask As Integer
	Dim retVal As Integer
	retVal = 0
	myMask = &H001
	For currPos = SDValueMin To SDValueMax
		If (iOptions AND myMask) > 0 Then retVal = retVal + 1
		myMask = myMask * 2
	Next	
	CountBits = retVal
End Function


Function CheckBit (iOptions, iPos As Integer) As Boolean
	Dim myMask As Integer
	Dim retVal As Boolean
	retVal = false
	If (iPos > 0) AND (iPos < 16) Then	
		myMask = 1 * (2^(iPos-1))
		retVal = (iOptions AND myMask) > 0
	End If
	CheckBit = retVal
End Function


Function Options2Bits (iOptions As Integer) As Long
	Dim currNumber as Integer
	Dim retVal As Long
	retVal = 0
	For currNumber = SDValueMax+1 To SDValueMin Step -1
		retVal = retVal * 10
		If CheckBit (iOptions, currNumber) Then retVal = retVal + 1
	Next
	Options2Bits = retVal
End Function


Function Options2String (iOptions  As Integer, Optional iBits As
Integer, Optional bNumber as Number) As String
	Dim currNumber as Integer
	Dim retVal As String
	retVal = ""
	If IsMissing (iBits) Then iBits = 9
	If IsMissing (bNumber) Then bNumber = true
	For currNumber = iBits To 1 Step -1
		If CheckBit (iOptions, currNumber) Then
			retVal = retVal & "1"
		Else
			retVal = retVal & "0"
		End If
	Next
	If bNumber Then
		retVal = "[ " & retVal & " ]"
	Else
		retVal = "< " & retVal & " >"
	End If
	Options2String = retVal
End Function

'	:	:	:
'	:	:	:

Wolf 'und nein, du willst ganz sicher /nicht/ die ganzen inzwischen
knapp 2.000 Zeilen haben, glaube mir' gang
-- 
Donald Trump ist ein großer Visionär, der seiner Zeit weit voraus ist:
Er verbreitet schon jetzt den Slogan "make America great again", obwohl
dieser erst in der Ära /nach/ ihm seine volle Bedeutung entfalten wird.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-de-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-de-help@openoffice.apache.org


Mime
View raw message