+ Transactions between Variables

Prev Next

Introduction

Different from transactions without assignment operators, the + assignment operator in front of the transaction symbol will assume the following rules focussing on overlaying data from the source variable in the destination variable:

  • Transactions can be carried out on base variables as well as member variables.
  • If the destination variable does not yet exist, then it will be created as simple variable containing void value before the transaction begins. However, the source variable on the right-hand side must exist.
  • The existing setup of structure and array members and sub-members in the destination variable may be extended:
    • Further arrays and/or structures may be added.
    • Additional members may be added to existing arrays and/or structures.
    • Destination memebers for which equivalent source members are existing will, which is different from the | prfix, not be overwritten.
  • Where possible, all structure and array members and sub-members of the source variable will be included in the transaction.
  • The base variable of the specified destination will be overwritten if the ^ suffix is not used.



Following actions are applied on the destination variables using this assignment operator:

Destination Source Description
Simple or zero members Simple or zero members The value of the base variable will be transferred as long no ^ suffix is specified.
Simple or zero members Array Base variable: See above. The array (including sub-members) will be transferred.
Simple or zero members Structure Base variable: See above. The structure (including sub-members) will be transferred.
Structure Simple or zero members Base variable: See above.
Structure Array Base variable: See above. The array members will be renamed to structure members where the member names are 8-digit text representations of the index number, e.g. '00000000', '00000001', etc. After this, same rules as for structures described below apply.
Structure Structure Base variable: See above. The structure (including sub-members) will be transferred. - Existing members will not be overwritten
- All members in the source variable will be added as furhter members to the destination array.
- Existing members will not be overwritten
Array Simple or zero members Base variable: See above.
Array Array Base variable: See above. The array will be copied. - All members in the source variable will be added as furhter members to the destination array.
- Existing members will not be overwritten
Array Structure Base variable: See above. The members for which corresponding member positions are already existing in the destination variable will also be transferred. The existing array members will be replaced by structure members from the source variable, sorted in alphabetic order by member names.
- All members in the source variable will be added as furhter members to the destination array.
- Existing members will not be overwritten

Copy Transaction Example
       structure( animals1[], { mammal, bird, fish }, { dog, owl, eel} );
       structure( animals1[mammal], { carnivore, herbivore }, { bear, deer } );
       array ( animals1[insects], { bee, fly } );

       structure( animals2[], { mammal, fish, reptile }, { cat, trout, turtle } );
       structure( animals2[mammal], { carnivore, omnivores }, { lynx, skunk } );
       array ( animals2[insects], { ant, tick, mosquito } );

       animals1[] +<== animals2[];  // animals1 gets all insects members, omnivore (skunk) and the turtle
       see(animals1[]);
animals1[]              [Void]                     (void,full access)
bird                    owl                        (softquoted string,full access)
fish                    eel                        (softquoted string,full access)
insects                 [Void]                     (void,full access)
  Array [   0]          bee                        (softquoted string,full access)
  Array [   1]          fly                        (softquoted string,full access)
  Array [   2]          ant                        (softquoted string,full access)
  Array [   3]          tick                       (softquoted string,full access)
  Array [   4]          mosquito                   (softquoted string,full access)
mammal                  dog                        (softquoted string,full access)
  carnivore             bear                       (softquoted string,full access)
  herbivore             deer                       (softquoted string,full access)
  omnivores             skunk                      (softquoted string,full access)
reptile                 turtle                     (softquoted string,full access)

Try it yourself: Open LAN_Features_ADD_Transactions_between_variables.b4p in B4P_Examples.zip. Decompress before use.
Copy Transaction Example among Structures and Arrays
       structure( animals1[], { mammal, bird, fish }, { dog, owl, eel} );
       structure( animals1[mammal], { carnivore, herbivore }, { bear, deer } );
       array ( animals1[insects], { bee, fly } );

       structure( animals2[], { mammal, fish, reptile }, { cat, trout, turtle } );
       array( animals2[mammal], { lynx, skunk } );
       structure ( animals2[insects], { useful, nasty, useless }, { ant, tick, mosquito } );

       animals1[] +<== animals2[];  // animals1 gets all insects members, omnivore (skunk) and the turtle
       see(animals1[]);
animals1[]              [Void]                     (void,full access)
bird                    owl                        (softquoted string,full access)
fish                    eel                        (softquoted string,full access)
insects                 [Void]                     (void,full access)
  Array [   0]          tick                       (softquoted string,full access)
  Array [   1]          ant                        (softquoted string,full access)
  Array [   2]          mosquito                   (softquoted string,full access)
mammal                  dog                        (softquoted string,full access)
  Array [   0]          bear                       (softquoted string,full access)
  Array [   1]          deer                       (softquoted string,full access)
  Array [   2]          lynx                       (softquoted string,full access)
  Array [   3]          skunk                      (softquoted string,full access)
reptile                 turtle                     (softquoted string,full access)

Try it yourself: Open LAN_Features_ADD_Transactions_between_variables_01.b4p in B4P_Examples.zip. Decompress before use.
Move Transaction Example
       structure( animals1[], { mammal, bird, fish }, { dog, owl, eel} );
       structure( animals1[mammal], { carnivore, herbivore }, { bear, deer } );
       array ( animals1[insects], { bee, fly } );

       structure( animals2[], { mammal, fish, reptile }, { cat, trout, turtle } );
       array( animals2[mammal], { lynx, skunk } );
       structure ( animals2[insects], { useful, nasty, useless }, { ant, tick, mosquito } );

       animals1[mammal] +<<= animals2[ mammal ];

       see(animals1[]);
       see(animals2[]); // Without the mammals
animals1[]              [Void]                     (void,full access)
bird                    owl                        (softquoted string,full access)
fish                    eel                        (softquoted string,full access)
insects                 [Void]                     (void,full access)
  Array [   0]          bee                        (softquoted string,full access)
  Array [   1]          fly                        (softquoted string,full access)
mammal                  cat                        (softquoted string,full access)
  Array [   0]          bear                       (softquoted string,full access)
  Array [   1]          deer                       (softquoted string,full access)
  Array [   2]          lynx                       (softquoted string,full access)
  Array [   3]          skunk                      (softquoted string,full access)

animals2[]              [Void]                     (void,full access)
fish                    trout                      (softquoted string,full access)
insects                 [Void]                     (void,full access)
  nasty                 tick                       (softquoted string,full access)
  useful                ant                        (softquoted string,full access)
  useless               mosquito                   (softquoted string,full access)
reptile                 turtle                     (softquoted string,full access)

Try it yourself: Open LAN_Features_ADD_Transactions_between_variables_02.b4p in B4P_Examples.zip. Decompress before use.
Swap Transaction Example
       structure( animals1[], { mammal, bird, fish }, { dog, owl, eel} );
       structure( animals1[mammal], { carnivore, herbivore }, { bear, deer } );
       array ( animals1[insects], { bee, fly } );

       structure( animals2[], { mammal, fish, reptile }, { cat, trout, turtle } );
       structure( animals2[mammal], { carnivore, omnivores }, { lynx, skunk } );
       array ( animals2[insects], { ant, tick, mosquito } );

       animals1[] +<=> animals2[];  
       see(animals1[]); // Keep dog, owl eel, bear, deer, bee, fly. Get turtle, skunk and all insects
       see(animals2[]); // Keep cat, trout, turtle, lynx, skunk. Get owl, deer and all insects
animals1[]              [Void]                     (void,full access)
bird                    owl                        (softquoted string,full access)
fish                    eel                        (softquoted string,full access)
insects                 [Void]                     (void,full access)
  Array [   0]          bee                        (softquoted string,full access)
  Array [   1]          fly                        (softquoted string,full access)
  Array [   2]          ant                        (softquoted string,full access)
  Array [   3]          tick                       (softquoted string,full access)
  Array [   4]          mosquito                   (softquoted string,full access)
mammal                  dog                        (softquoted string,full access)
  carnivore             bear                       (softquoted string,full access)
  herbivore             deer                       (softquoted string,full access)
  omnivores             skunk                      (softquoted string,full access)
reptile                 turtle                     (softquoted string,full access)

animals2[]              [Void]                     (void,full access)
bird                    owl                        (softquoted string,full access)
fish                    trout                      (softquoted string,full access)
insects                 [Void]                     (void,full access)
  Array [   0]          ant                        (softquoted string,full access)
  Array [   1]          tick                       (softquoted string,full access)
  Array [   2]          mosquito                   (softquoted string,full access)
  Array [   3]          bee                        (softquoted string,full access)
  Array [   4]          fly                        (softquoted string,full access)
mammal                  cat                        (softquoted string,full access)
  carnivore             lynx                       (softquoted string,full access)
  herbivore             deer                       (softquoted string,full access)
  omnivores             skunk                      (softquoted string,full access)
reptile                 turtle                     (softquoted string,full access)

Try it yourself: Open LAN_Features_ADD_Transactions_between_variables_03.b4p in B4P_Examples.zip. Decompress before use.