nested functions?

Home Forums General Programming nested functions?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #72751
    human fly
    Participant
      • Topics: 124
      • Replies: 1070
      • Total: 1194
      • ★★★★

      i have to add a condition to a method i call ‘partialOps’
      -similar to partialOnOff in the D-50 panel, ie:

      if 	p1 == 0 and p2 == 0 and p3 == 0 and p4 == 0 
      	then ... (etc.)

      and it runs through all possible combinations of the
      4 partial buttons, ie: 16 –

      i need to get it to check ‘level’ fader values for the corresponding
      partial onoff buttons – the idea is that level = 0 is the same
      as partial being ‘Off’. i’m doing that bit in another method
      called LevelZeroIsOff, which goes:

      if tvaLevelA ~= 0 and tvaLevelB ~= 0	--both levels on
       and p1 == 1 and p2 == 1 then ...

      – it runs through the various possibilities, and is for
      controlling a led display for each partial’s state, ie:
      whether it is on or off.

      both can control the led display, in their own way.
      levelZero thing works fine, and the partialOps thing works
      fine, but partialOps doesn’t yet know how to get the state
      of the level faders when i switch a partial back on ..
      ie: display is wrong after using the button. it’s a simple
      matter of adding a ‘getValue’ for level faders and including
      that in my ‘longform’ partialOnoff method.

      i can see this requiring a huge amount of new condition entries
      and a long long method, potentially.

      so i’ve seen some nested stuff before, but i’m not at this point
      sure how that works, and what must take precedence. i also
      thought of changing the whole thing and making little functions
      i can call – it would at least make it easier to work on, maybe.

      i guess i’ll figure this out next session, but would appreciate
      any ideas – just say if my explanation is rubbish !

      also thought that maybe just including the whole thing in one
      big partial onoff method could be another way – i’m doing all
      of this longform at the moment, declaring everything in the
      method rather than at startup, while i get it working.

      #72752
      human fly
      Participant
        • Topics: 124
        • Replies: 1070
        • Total: 1194
        • ★★★★

        (i probably used the wrong terminology)

        okay, i see how this is done: you just start a new
        if...then ...elseif...then... etc..end argument within
        the original one.

        (saw an example of this in the matrix1k panel)

        edit*(later on…): um, well, my method doesn’t quite work
        yet, what a monster.. might have to workaround. but the
        basic principle does. may have to upload a demo file
        some time.

      Viewing 2 posts - 1 through 2 (of 2 total)
      • The forum ‘Programming’ is closed to new topics and replies.
      There is currently 0 users and 86 guests online
      No users are currently active
      Forum Statistics
      Threads: 2,495, Posts: 17,374, Members: 77,605
      Most users ever online was 12 on January 22, 2019 3:47 pm
      Ctrlr