SDK: Get total number of scenes and max length of a scene name

  • Hello Mark and Isadora developers,

    I'm rewriting dbengali's plugin JumpByName ([]( as I'd like to use it on Windows.
    The way I proceed is quite simple:
    • browse all scenes in a 'for' loop
    • if the name of the currently requested scene (I use the GetSceneName_ function defined in IsadoraCallbacks.h) matches the requirements according to the parameters, jump to this scene
    But this approach raises 2 problems:
    1. The 'for' loop needs a boundary. For now I hardcoded it in a constant, assuming that no Isadora project would use more than, say, 2000 scenes.
    2. The GetSceneName_ function requires a maxLen parameter, which seems to be the size of the string it fills with the scene name. I also used a constant, assuming that no one would have a scene name of 1000 characters.
    I would like the performance to be optimal, not to mention the ugliness of these solutions. Hence these 2 questions:
    1. Is there a way to get the total number of scenes in an Isadora project dynamically (something like GetNumberOfScenes_ ?), or at least the maximum size of the scene array (if it's not dynamically assigned) ?
    2. Same question for the size of the scene name string (a constant maybe?)
    Thanks in advance.

  • Just a little update. I finally managed to solve problem #1, I just replaced the 'for' loop with a do/while: knowing that GetSceneName_ fills the string parameter back with empty content (""), it can be tested as a loop end condition.

    char loopCurrentSceneName[SCENE_NAME_MAX_LENGTH];
    int i = 1; // scene index (one-based)
    GetSceneName_(ip, inActorInfo, mode, i, SCENE_NAME_MAX_LENGTH-1, loopCurrentSceneName); // loopCurrentSceneName pointer now points to the scene name at current index
    }while (strcmp(loopCurrentSceneName, "") != 0); // Loop while a scene name is found in scene list
    As you can see, I didn't solve problem #2 (kept the SCENE_NAME_MAX_LENGTH constant defined in linked .h file), but after all it's no big deal.
  • Tech Staff

    Cool.. the name length is not such an issue..
    thanks for putting in the hard work.

  • Sorry again to disappear while you were working on this and not to save you time!

    For #2 I made a similar choice, though I set the max length to 128\.  I believe I left a warning in the actor help about keeping scene labels less than 128 characters.  You were more generous :)
    For #1 I also wonder if there is a way to find out the number of scenes somewhere, but I assumed that the scene list is maybe stored internally as a linked list rather than an array, in which case, there isn't necessarily a way to know the number of scenes other than navigating the list.  So, while iterating through the scenes looking for the search string, I just catch the error "kIzzyErr_SceneDoesntExist" to know if I have run past the end of the scene list, and thus can stop checking.  This conveniently avoids the need for a constant boundary on number of scenes.
    hope this helps, even though it is a bit late.

  • No problem, dbengali, thanks for your post anyway. The try/catch approach is interesting too, seems more robust in case of a change in the API.

  • Oh... I see. No try/catch, just the return value compared to the kIzzyErr_SceneDoesntExist constant.

    I'm feeling lazy to adapt my source right now, I'll keep the empty string comparison for now... works well too.