10-02-2025 04:17 PM
NOTE: Anyone helping please ignore the messiness of lines 334 -364 as they were some last ditch efforts as I continues to confuse myself with this topic
Setting : Diadem, VB, Scripting
Attachments will include :
- Error message while researching
- The watch panel not working in certain settings
- Script itself
Version of DIADEM: 2025 Q2, Build number 25.3.0f9582
My experience: Associate Engineer : degree: computer engineering, I have not programmed in VB before 2 weeks ago and the script was started from scratch
Problem: I may have confused myself but I have done a deep dive today because I ran into an extremely long run time with my script.
- In the current script that is uploaded this double nested loop originated at line 373.
-After researching and better understanding channels I realized computations and Read/writes could become much faster with block operations.
- Once I began finding info on block operations I wanted pre-set the size of my array to the size of my channels which is Eqv to 1228801
- in an ideal situation that would not change, but I have been programming too long to trust that. Hense I created this line "Dim myDataArray(Data.Root.ChannelGroups(3).Channels("FilteredSignal_PhaseW").Properties("length").Value)" Where I encounter "Error1" - png attached
- After doing some investigation in the data portal and the watch tab at the bottom I was extremely confident it was 1228801, Look at "ErrorCheck1"
- BUT if you drag that number over from the data portal to create this line "CInt(Data.Root.ChannelGroupd(3).Channels("FilteredSignal_PhaseW").properties("length").values)" you get "Error2"
-I believed I solved it by using "myDataArray = oChannel.GetValuesBlock(1, oChannel.Size, eValueBlockVbArray)" After doing some reading on block operation.
- When I run a for loop and count out the loops it comes out to be the correct number. YET, doing UBound will not return anything in the watch tab, and according to CInt, it cannot take 1228801 without overflowing.
MY QUESTIONS: I do not know why but many things seem to be contradicting each other here. I do not feel content with just moving on until I can understand CInts and what they represent in DIAdem; At a minimum I think it is crucial to understand why the error message is calling for a CInt and why a regular CInt is giving me overflow. Are the error messaging incorrect?
- Overall I am unsure, and any bit of knowledge would help
Solved! Go to Solution.
10-06-2025 06:27 AM
Just some basics (rather standard VBS than DIAdem specific)
dim Array(size) requires a constant for size.
Use redim instead when trying to create an array where size is set via variable.
Integer is limited to –32.768 - 32.767, so if you channel is longer this will cause an error.
I suggest to have a detailed look into DIAdem help which is comprehensive and very helpful.
10-06-2025 10:31 AM
Thank you for your response, I will definitely being doing more of a deep dive. If the information is out there I would like to understand the purpose of allocating memory as a constant first. I had to do a basic memory allocation program in college but that knowledge has not been used in years.