Trimming empty rows from array

Viewing 4 reply threads
  • Author
    Posts
    • #3780
      Balázs Fürtön
      Participant

      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

    • #3788
      Bruce Walker
      Participant

      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/65450406

      AC20 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

    • #3792
      Balázs Fürtön
      Participant

      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.

      https://archicad-talk.graphisoft.com/viewtopic.php?t=4677&postdays=0&postorder=asc&&start=0&sid=21bf9a70de2609686e1f7e68602c9d41

      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

    • #3793
      Gergely Fehér
      Keymaster

      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

    • #3794
      Balázs Fürtön
      Participant

      Thank you, this eliminated my last warning!:)

      Balazs Furton

      Student of architecture @ Budapest University of Technology and Economics

Viewing 4 reply threads
  • The forum ‘Documentation elements, text handling’ is closed to new topics and replies.