-
FlexPro
- Zoom sur FlexPro
- Fonctionnalités & Options
- Domaines d’application
- Tous les avantages
- Nouveau dans FlexPro 2021
- Testez FlexPro gratuitement
- FlexPro View OEM Freeware
- Conseils d’achat
- Login
- Langue
-
-
-
- +49 6894 929600
- infoweisang.com
- Google Maps
- Produits
- News
- Support
- Société
- Emplois
- Contact
- Login
- Langue
-
-
-
- +49 6894 929600
- infoweisang.com
- Google Maps
Copy array data in a dataset using Range
Accueil > Community > Automation and VBA > Copy array data in a dataset using Range
- This topic has 4 replies, 2 voices, and was last updated 15 years, 5 months ago by
norbert.bakkers@lr.org.
-
AuthorPosts
-
November 11, 2009 at 2:27 am #12382
norbert.bakkers@lr.org
ParticipantI’ve been trying to get data from a simple test array in a dataset using the Range command. Using the ‘Transferring Large Data Sets Section by Section’ example as a guide I made the following procedure:
Private Sub CommandButton2_Click() Dim TmpArr(1 To 3) As Single TmpArr(1) = 2 TmpArr(2) = 3 TmpArr(3) = 4 With ActiveDatabase.RootFolder.Add("Signal", fpObjectTypeDataSet) .DataStructure = fpDataStructureDataSeries .DataType(fpDataComponentAll) = fpDataTypeFloat32 .NumberOfRows = 3 .FillColumns "(NumberOfRows(i), FloatingPoint32 0, FloatingPoint32 0)", fpDataComponentAll .Update End With ActiveDatabase.RootFolder.Object("Signal").Range(fpDataComponentAll).Value = TmpArr End Sub
This routing crashes at the Range statement with an ‘Invalid procedure or argument’ error. What am I doing wrong?
Also, if this is all working, I would like to transfer data from a multidimensional array (50 columns) in 50 individual datasets. Is it possible to do this using the Range statement. In other words, how do I select 1 column in the array?
November 11, 2009 at 2:27 am #8065norbert.bakkers@lr.org
ParticipantI’ve been trying to get data from a simple test array in a dataset using the Range command. Using the ‘Transferring Large Data Sets Section by Section’ example as a guide I made the following procedure:
Private Sub CommandButton2_Click() Dim TmpArr(1 To 3) As Single TmpArr(1) = 2 TmpArr(2) = 3 TmpArr(3) = 4 With ActiveDatabase.RootFolder.Add("Signal", fpObjectTypeDataSet) .DataStructure = fpDataStructureDataSeries .DataType(fpDataComponentAll) = fpDataTypeFloat32 .NumberOfRows = 3 .FillColumns "(NumberOfRows(i), FloatingPoint32 0, FloatingPoint32 0)", fpDataComponentAll .Update End With ActiveDatabase.RootFolder.Object("Signal").Range(fpDataComponentAll).Value = TmpArr End Sub
This routing crashes at the Range statement with an ‘Invalid procedure or argument’ error. What am I doing wrong?
Also, if this is all working, I would like to transfer data from a multidimensional array (50 columns) in 50 individual datasets. Is it possible to do this using the Range statement. In other words, how do I select 1 column in the array?
November 11, 2009 at 3:18 am #8587Bernhard Kantz
Participant1) At the moment the range method only works if all arguments are defined.
Example:Dim TmpArr(1 To 3) As Single TmpArr(1) = 2 TmpArr(2) = 3 TmpArr(3) = 4 With ActiveDatabase.RootFolder.Add("Signal", fpObjectTypeDataSet) .DataStructure = fpDataStructureDataSeries .DataType(fpDataComponentAll) = fpDataTypeFloat32 .NumberOfRows = 3 .Range(fpDataComponentY, 1, 1, .NumberOfColumns, .NumberOfRows).Value = TmpArr .Update End With
2) Create a FPScript formula for each dataset and use the index operator.
Sub MatrixToDataSeries() Dim oMatrix As DataSet Set oMatrix = ThisDatabase.RootFolder.Object("Matrix", fpObjectTypeDataSet) Dim oFml As Formula For i = 1 To oMatrix.NumberOfColumns Set oFml = ThisDatabase.RootFolder.Add("Dataset" & CStr(i), fpObjectTypeFormula) With oFml .Formula = "Matrix[" & i - 1 & "]" .Update .Evaluate End With Next i End Sub
November 11, 2009 at 7:45 pm #8588norbert.bakkers@lr.org
ParticipantThank you for the quick reply.
I wasn’t aware that all components of the Range method had to be specified. Flexpro help (Version 7) has these specified as optional, so I left them out. However, the routine is working fine now, thanks for that.Regarding the second question:
I didn’t specify this very clear, but the multidimensional matrix is a VBA matrix, not a Flexpro matrix. I am struggling to select individual columns in the VBA matrix.
I can now copy the whole matrix from VBA to a Flexpro DataMatrix (using Range) and then split them into individual datasets. However, I would prefer to copy the data columns straight from the VBA matrix to the Flexpro datasets.November 11, 2009 at 8:38 pm #8589Bernhard Kantz
ParticipantAlternatively you have to copy the column values into a new variable.
Example:Dim TmpArr(1 To 3, 1 To 2) As Single TmpArr(1, 1) = 1 TmpArr(2, 1) = 2 TmpArr(3, 1) = 3 TmpArr(1, 2) = 4 TmpArr(2, 2) = 5 TmpArr(3, 2) = 6 ReDim TmpArr2(LBound(TmpArr, 2) To UBound(TmpArr, 2)) As Single For i = LBound(TmpArr) To UBound(TmpArr) For j = LBound(TmpArr2) To UBound(TmpArr2) TmpArr2(j) = TmpArr(i, j) Next j ' Create DataSet Next i
-
AuthorPosts
- You must be logged in to reply to this topic.
Vous êtes actuellement en train de consulter le contenu d'un espace réservé de Facebook. Pour accéder au contenu réel, cliquez sur le bouton ci-dessous. Veuillez noter que ce faisant, des données seront partagées avec des providers tiers.
Plus d'informationsVous devez charger le contenu de reCAPTCHA pour soumettre le formulaire. Veuillez noter que ce faisant, des données seront partagées avec des providers tiers.
Plus d'informationsVous êtes actuellement en train de consulter le contenu d'un espace réservé de Instagram. Pour accéder au contenu réel, cliquez sur le bouton ci-dessous. Veuillez noter que ce faisant, des données seront partagées avec des providers tiers.
Plus d'informationsVous êtes actuellement en train de consulter le contenu d'un espace réservé de X. Pour accéder au contenu réel, cliquez sur le bouton ci-dessous. Veuillez noter que ce faisant, des données seront partagées avec des providers tiers.
Plus d'informations