Row / Column assignment inconsistency / problems
issueid=265 04-03-2011 10:49
Super Moderator
Number of reported issues by Petr Schreiber: 126
Row / Column assignment inconsistency / problems
The row assignment is not possible in declaration, different behavior of same code in declaration and during later use

Hi,

there are some issues with row order assignment introduced in 1.8.6.0:

* Assignment is handled differently when assigning in declare and when "later"
* Row order assignment is not possible in declare


The issue is demonstrated in this sample:
Uses "Console"

'Dim m2(2, 2) As Ext = [ 1, 2,    ' row order assignment refused by run time error
'                        3, 4 ]


Dim m2(2, 2) As Ext = 1, 2,
                      3, 4
MyMat_Print(m2, "After column assignment to declare (and it is column assigned, correct)")

m2() = 1, 2,
       3, 4

MyMat_Print(m2, "After column assignment later in code (but it is row assigned, incorrect)")

m2() = [ 1, 2,
         3, 4 ]

MyMat_Print(m2, "After row assignment later in code (but it is column assigned, incorrect)")
                  
PrintL "Press any key to continue..."
WaitKey

'------------------------------------------------------------
Sub MyMat_Print(ByRef Matrix() As Ext, Optional ByVal sComment As String, ByVal Looper As Long, ByVal tTime As Double)
'------------------------------------------------------------
  Local i, j As Long
  
  If UBound(Matrix) = 0 Then
    PrintL "[" & sComment & "]"
    PrintL "Matrix not yet dimensioned"
    PrintL
    Exit Sub
  End If      
  
  PrintL "[" & sComment & "]" & IIf$(Looper > 0, " [Time for " & Looper & " loops: " & Format$(tTime, "#0.0000") & " secs]", "")
  For i = 1 To UBound(Matrix, 1)      
              
    For j = 1 To UBound(Matrix, 2)
      Print Str$(Matrix(i,j))+$TAB
    Next
    PrintL

  Next
      
  PrintL
      
End Sub
Issue Details
Issue Number 265
Issue Type Task
Project thinBasic
Category Core engine (thinCore.dll)
Status In Progress
Priority 2
Target Version 1.8.8
Completed Version (none)
Milestone thinBasic 2.0.0.0
Votes to perform 0
Votes not to perform 0
Assigned Users (none)
Tags (none)




25-04-2011 16:40
Super Moderator
There was a typo in original code listing, making the code impossible to run. Now it should go ok.


Petr

09-05-2011 15:27
thinBasic author
Petr, can you please test attached Core engine and let me know?
Thanks
Eros

09-05-2011 18:53
Super Moderator
Hi Eros,

it is promising, new core handles it correctly, except this case, which is still refused by parser:
Uses "Console"
 
' -- Row order assignment
Dim m2(2, 2) As Ext = [ 1, 2,
                        3, 4 ]
                        
MyMat_Print(m2, "After row assignment to declare")
 
PrintL "Press any key to continue..."
WaitKey
 
'------------------------------------------------------------
Sub MyMat_Print(ByRef Matrix() As Ext, Optional ByVal sComment As String, ByVal Looper As Long, ByVal tTime As Double)
'------------------------------------------------------------
  Local i, j As Long
   
  If UBound(Matrix) = 0 Then
    PrintL "[" & sComment & "]"
    PrintL "Matrix not yet dimensioned"
    PrintL
    Exit Sub
  End If     
   
  PrintL "[" & sComment & "]" & IIf$(Looper > 0, " [Time for " & Looper & " loops: " & Format$(tTime, "#0.0000") & " secs]", "")
  For i = 1 To UBound(Matrix, 1)     
               
    For j = 1 To UBound(Matrix, 2)
      Print Str$(Matrix(i,j))+$TAB
    Next
    PrintL
 
  Next
       
  PrintL
       
End Sub
Thanks,
Petr

15-05-2011 12:33
thinBasic author
Attached a new thinCore.dll (see bottom of this thread) that hopefully should fix the problem.

Eros

21-05-2011 19:42
Super Moderator
Quote Originally Posted by ErosOlmi
Attached a new thinCore.dll (see bottom of this thread) that hopefully should fix the problem.
Eros
Hi Eros,

my apologies, I missed this somehow. Yes, I can confirm the new core fixes all problems I could find.
I will update the sample scripts and will send them to you ASAP.

Great job!,
Petr

+ Reply