Home › Forums › Problems and solutions in GDL › Documentation elements, text handling › Trimming empty rows from array
Tagged: Array, array length
- This topic has 4 replies, 3 voices, and was last updated 6 years, 9 months ago by Balázs Fürtön.
-
AuthorPosts
-
-
January 29, 2018 at 12:41 #3780Balázs FürtönParticipant
Hi,
is there a way to eliminate empty array rows?
Currently what I’m doing is:n = vardim1 (WALL_SKINS_BMAT_NAMES) ! checking array length !text2 0,0,n dim _compSkinNum[] ! removing empty records from array for i=1 to n if WALL_SKINS_PARAMS[ i][2] # 0 then _compSkinNum[ i] = WALL_SKINS_PARAMS[ i][2] endif next i n = vardim1 (_compSkinNum) ! checking trimmed array length text2 0,0,n
But this gives me a warning: “Use of real types can result in precision problems at line XX in the 2D script of file YY.gsm”
AFAIK this warning will not impact the running of the script, but is there a way to get this done without getting the warning message?Thanks!
Balazs Furton
Student of architecture @ Budapest University of Technology and Economics
-
January 31, 2018 at 08:11 #3788Bruce WalkerParticipant
I don’t think this is the array – rather I suspect it would be that you are testing something that should be a length or integer value. Have a look at the line where the error occurs to see if you are mixing two different types.
www.brucepwalker.com
https://www.mindmeister.com/65450406AC20 6005 AUS Full & AC 21 3009 NZE Full | Win 10 Pro 64 | Intel i7-7700HQ 2.80GHz | 16 Gb RAM
NVIDIA GeForce GTX 1060 8Mb -
January 31, 2018 at 08:49 #3792Balázs FürtönParticipant
Initially what I’m doing is loading the wall skin list values to a new array: originally it is stored in a fixed one with ?? rows. I usually have less than that, and when I want to display elements from the original, I only want to see the filled ones.
So to trim, I compare the values against zero. When it is not zero, the record gets copied – this is where the problem lies: I’m comparing a real number against zero. On the Achicad-Talk forum I found threads regarding this problem, and it seems there is not much to do about it, rather than eliminating exact comparisons and to replace them by a “smaller than” relation.
I’m not that comfortable with programming, so I am not sure whether this is the way to go, or a different approach is more sufficient.
Edit: Probably I could use a “while” statement with the original array, with a “bigger than” comparison.
Balazs Furton
Student of architecture @ Budapest University of Technology and Economics
-
January 31, 2018 at 09:06 #3793Gergely FehérKeymaster
if WALL_SKINS_PARAMS[ i][2] # 0 then –> if abs(WALL_SKINS_PARAMS[ i][2]) > 0.0001 then
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE -
January 31, 2018 at 18:42 #3794Balázs FürtönParticipant
Thank you, this eliminated my last warning!:)
Balazs Furton
Student of architecture @ Budapest University of Technology and Economics
-
-
AuthorPosts
- The forum ‘Documentation elements, text handling’ is closed to new topics and replies.