Page 1 of 1
ReDim var holding an array of User Type fails
Posted:
Wed Apr 17, 2013 11:46 pm
by Henning
While working on accessing a MySQL database using Records.Value, to be closer to an old VB'ers ADO.
ReDim a Public variable holding an array of User Type fails!!
In Global: Public Dim ArtRec[1] As rcArt, rcArt is a User Type.
In Module1: ReDim ArtRec[recCount + 1] !!!! This is what screws-up the array.
If I in Global: Public Dim ArtRec[10] As rcArt and comment out the ReDim it works correctly.
/Henning
Re: ReDim var holding an array of User Type fails
Posted:
Thu Apr 18, 2013 6:57 pm
by Slowdown
Henning,
No errorÅ› reported here.
in Global;
- Code: Select all
Type rcArt
arNr As Short
arArt As String * 20
arSize As Short
arType As String
arID As String * 15
arIndate As String
arInpris As Short
arAntut As Short
arTotut As Integer
arStat As Byte
arKvnr As Short
arRedat As String
arKr As Integer
arKrtot As Integer
arAge As Short
arPris As Short
End Type
Public Dim ArtRec[1] As rcArt
In Mainwindow;
- Code: Select all
Dim recCount As Integer
Event Init()
recCount = 10
ReDim ArtRec[recCount + 1]' !!!!This Is what screws - up the array.
End Event
Did not test it further but this code works with no error on Linux 64bit.
Re: ReDim var holding an array of User Type fails
Posted:
Thu Apr 18, 2013 8:15 pm
by Henning
It's when running the prog. and ReDim ArtRec[] then at "ArtRec[rc].arType = Records.Value(sRecordsId, fld)" it screws-up, with the RunTimeError.
Also if I comment all those lines, and do MainWindow.txtSomeLineEdit = Records.Value(sRecordsId, fld) all is fine.
/Henning
Re: ReDim var holding an array of User Type fails
Posted:
Fri Apr 19, 2013 12:03 am
by Henning
I really don't understand what is going wrong. With or without the ReDim compiles to the exact same C++ code...
- Code: Select all
With ReDim
do {
/*DEBUG*/Q7BS("Module1.Module.q7b", "GetArt", "137", "1");
Q7B_ASSIGNMENT(&fld, &Q7B__STRING(Q7B_ID("artnr")));
/*DEBUG*/Q7BS("Module1.Module.q7b", "GetArt", "138", "1");
Q7B_ASSIGNMENT(q7b_type_get(*q7b_array_at(Q7B_Global_Class(Q7B_Global_Object())->ArtRec, rc, Q7B_ID((qint64) -1), Q7B_ID((qint64) -1), Q7B_ID((qint64) -1)), Q7B_ID((qint64) 0), Q7B_ID(-1), Q7B_ID(-1), Q7B_ID(-1), Q7B_ID(-1)), &Q7B__SHORT(Q7B_RECORDS_VALUE(Q7B_Records_Object(), sRecordsId, Q7B_ID("artnr"))));
/*DEBUG*/Q7BS("Module1.Module.q7b", "GetArt", "140", "1");
Without ReDim
do {
/*DEBUG*/Q7BS("Module1.Module.q7b", "GetArt", "137", "1");
Q7B_ASSIGNMENT(&fld, &Q7B__STRING(Q7B_ID("artnr")));
/*DEBUG*/Q7BS("Module1.Module.q7b", "GetArt", "138", "1");
Q7B_ASSIGNMENT(q7b_type_get(*q7b_array_at(Q7B_Global_Class(Q7B_Global_Object())->ArtRec, rc, Q7B_ID((qint64) -1), Q7B_ID((qint64) -1), Q7B_ID((qint64) -1)), Q7B_ID((qint64) 0), Q7B_ID(-1), Q7B_ID(-1), Q7B_ID(-1), Q7B_ID(-1)), &Q7B__SHORT(Q7B_RECORDS_VALUE(Q7B_Records_Object(), sRecordsId, Q7B_ID("artnr"))));
The error scrn is in Q&A < Array of User Type Error
/Henning
Re: ReDim var holding an array of User Type fails
Posted:
Fri Apr 19, 2013 6:28 pm
by Slowdown
Willing to compile/test it on Linux just dump the project.
Re: ReDim var holding an array of User Type fails
Posted:
Sat Apr 20, 2013 9:09 am
by Slowdown
Hi Henning,
Did test the code i posted with XP and again no error's.
After some brainstorming is the problem you have really with DIM or REDIM or is it something else (Records.) and the error reported by Q7B
pointing you into the wrong direction ?