Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Transfer Variables between Prog. Blocks

Discussion in 'Programming Questions and Suggestions' started by Warixx, Apr 20, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. Warixx Trainee Engineer

    Messages:
    85
    Variables declared outside Main() are just global in the sense that they keep their value between runs of this exact entity of a programmable block but cannot be accessed from other programmable blocks, is this correct? So is the only method of transferring information between PB via some block-name-workaround?
     
  2. plaYer2k Master Engineer

    Messages:
    3,160
    Correctly. You can only transfer values and not references.
    You always need to either name a block or text within text panels, or use blocks with floats or integer values to transfer them.
    Using text and parsing float/int values works too of course.

    Edit:
    Though most still hope that we will get an option to call functions on other programmable blocks aswell as call programmable blocks with arguments.
    I really hope to see a feature to transfer non-primitive data types like IMyEntity and all derived interfaces like IMyGridTerminalSystem, IMyAntennaBlock etc etc...
     
  3. Warixx Trainee Engineer

    Messages:
    85
    Thank you.
    Sorry, I cannot see the implications of being able to transfer these non-primitive data types, would this render something possible?
     
  4. plaYer2k Master Engineer

    Messages:
    3,160
    Absolutely. You could transfer a list of blocks, processed data, store datas in one PB to make them accessible for any other PB.
    So essentially your main advantage would be to reduce processing power as sometimes several PBs need to perform the same actions on the same data, thus some work is redundant.
    Furthermore you could structure your code more. Instead of building "classes" you would build PBs. So one PB would perform a tracking code and send the processed data to another PB which then processes the course of for an autopilot while then splitting the dataas to several other PBs which each represent subsystems for the actions that shall be prformed.

    Most of that can be done in one block with the low complexity we got, but at some point the instruction limit for execution and char limit for code will kick in noticeably.

    Also some other dirty tricks i dont want to lay out in detail :D
     
Thread Status:
This last post in this thread was made more than 31 days old.