Updated the script. Thanks to some help from Mike Lacey, it now puts Notes in to these newly created Empty Items.
https://stash.reaper.fm/oldsb/242619/...mpty_Items.zip
A demonstration with the data included in the ZIP.
http://screencast.com/t/MGVlNTAzZT
Since precise whitespace placement doesn't seem to matter, it shouldn't be too hard to adapt the routine to erase the current notes and replace them. You actually only need to erase all the lines that describe the notes (<NOTES\nstuff or not>) and insert new ones with the existing routine.
One thing I still need to implement is to check the given text for < and > characters, so they don't muck up the item.
The new code, implemented as a sub routine that takes the new text to be used as an argument :
Code:
my $text = $_[0]; # the only argument - the text to be inserted as a note
my @text_split = (); # where multiline text lives until we build the text block to be inserted
my $notes = (); # where we'll place the finished data to be inserted in to the item
my $delimiter = "\n";
my ($bool, $it, $chunk, $maxlen);
my $z;
my $length = -1;
my $result = "fail";
# Build the notes block
@text_split = split(/$delimiter/, $text); # split the text in to lines
chomp @text_split;
$notes = "<NOTES\n";
for ($z=0;$z<scalar(@text_split);$z++){
$notes = $notes . "|" . $text_split[$z] . "\n";
}
$notes = $notes . ">\n";
# Get the first selected item in the current project
$it = RPR_GetSelectedMediaItem(CURR_PROJ, 0);
# set-up for call to GetSetItemState
$chunk=""; # Get, not Set
$maxlen=2048; # max num of chars to return
# Get the ItemState
($bool, $it, $chunk, $maxlen) = RPR_GetSetItemState($it, $chunk, $maxlen);
$result = "pass" if $bool;
#RPR_ShowConsoleMsg("GetSetItemState reports $result\n$chunk\n");
# insert them after the IGUID line
$chunk =~s/(IGUID.*}\n)/$1$notes/;
# Set the ItemState
$result = "fail";
($bool, $it, $chunk, $maxlen) = RPR_GetSetItemState($it, $chunk, $maxlen);
$result = "pass" if $bool;
As you can see there's still a bit of cleanup to do. But it's ready for demoing at the presentation on friday.