Double adding to parameter

Viewing 3 reply threads
  • Author
    Posts
    • #3798
      James Murray
      Participant

      An object has an optional part at the top. When the user turns the option off, I would like to automatically decrease ZZYZX by the thickness of the optional part. When they turn it on, I would like to increase ZZYZX. This works, except the optional value is added or subtracted twice. Same result in master or parameter script.

      IF GLOB_MODPAR_NAME = 'bOption' & bOption THEN
      	ZZYZX = ZZYZX + optionThk
      	PARAMETERS ZZYZX = ZZYZX
      ENDIF
      IF GLOB_MODPAR_NAME = 'bOption' & NOT(bOption) THEN
      	ZZYZX = ZZYZX - optionThk
      	PARAMETERS ZZYZX = ZZYZX
      ENDIF

      James M

    • #3803
      Barry Kelly
      Participant

      The parameter script (or master as parameter script) will be run more than once so you need to trap it.
      This should help do that.
      From the GDL manual …

      First Occasion in Progress

      n = APPLICATION_QUERY (“parameter_script”, “firstoccasion_in_progress”, isFirstRun)

      This command returns whether the current run is the first run or a consequence of a previous execution of the parameter script which changed
      some parameters. This command has no additional parameters.
      The distinction may be important when a part of the parameter script executes a triggered event – e.g. it handles the pushing of a function button.
      isFirstRun: The returned value shows whether the current run is the first run

      Barry.

      Versions 6.5 to 22
      Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
      Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

    • #3806
      James Murray
      Participant

      Thanks, Barry , I thought it had to do with multiple executions. Strangely, it works correctly now when placed in the Master (adding and subtracting with the checkbox), but in the Parameter script the identical code always subtracts.

      rrr = APPLICATION_QUERY ("parameter_script", "firstoccasion_in_progress", isFirstRun)
      IF isFirstRun THEN
      	IF GLOB_MODPAR_NAME = 'bOption' THEN
      		IF bOption THEN
      			ZZYZX = ZZYZX + optionThk
      			PARAMETERS ZZYZX = ZZYZX
      		ENDIF
      		IF NOT(bOption) THEN
      			ZZYZX = ZZYZX - optionThk
      			PARAMETERS ZZYZX = ZZYZX
      		ENDIF
      	ENDIF
      ENDIF

      I’m working around it by using the MS, but it is odd IMO.

      James M

    • #3807
      Barry Kelly
      Participant

      Also now in the Compatibility Options in the Details page there is an option to run the parameter script once.
      I haven’t looked into this yet as I haven’t had the need.

      Barry.

      Versions 6.5 to 22
      Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
      Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

Viewing 3 reply threads
  • The forum ‘Graphical UI and parameters list’ is closed to new topics and replies.