Hope you can shed some light on this. I've been trying to solve this problem for about 8 hours now and I'm stuck.
I'm still trying to convert shared actions to functions in b.js because Toolbook cannot contain the number of shared actions I require. The problem concerns an array called triggers [] that I use in the TB HTML. It contains data (strings) used to trigger events while a media file is playing. When the project is saved the array is converted to textlines to be saved in a file and they might look something like this:
1978,1,First message...,2321,
4299,2,5000,,
7029,1,Second message...,1985,
9014,2,5000,,
so triggers [0] would be "1978,1,First message...,2321," and triggers[1] would be "4299,2,5000,," etc. Until now this has functioned perfectly. The problem is that I need to update the array from functions in my custom js file and this is not working.
Here is the action sequence I am trying to replace:

Here is the function I'm using to replace it in the js file:
- Code: Select all
function tbfunction_setTrigger(triggerLine, increment) {
tbfunction_pgTBObjSet("limits", "user", triggerLine + ";" + increment);
};
This is the action sequence in field "limits":

setTrigger is always activated from another function in the js file for example:
- Code: Select all
function tbfunction_textDisplay2(currentTrigger, currentTriggerLine, MSecs, unit) {
var triggerLine = [];
triggerLine = tbfunction_pgSplitToArray(currentTriggerLine);
var actionStart = triggerLine[0];
actionStart = actionStart * 1;
var lapseS = MSecs - actionStart;
triggerLine[3] = lapseS;
currentTriggerLine = triggerLine[0] + "," + triggerLine[1] + "," + triggerLine[2] + "," + triggerLine[3];
tbfunction_setTrigger(currentTriggerLine, false);
// -----------------------DEBUG-------------------------------
alert("currentTrigger = " + currentTrigger)
// A click on info activates a loop that shows the contents of triggers[]
tbfunction_pgTBObjSet("info", "click");
//------------------------------------------------------------
currentTrigger = currentTrigger * 1;
currentTrigger = currentTrigger + 1;
tbfunction_pgTBObjSet("info", "user", "currentTrigger," + currentTrigger);
var rightPos = tbfunction_pgTBObjGet("changepos", "left");
rightPos = rightPos + 28;
var leftPos = tbfunction_pgTBObjGet("startMarker", "left");
var myWidth = rightPos - leftPos;
tbfunction_pgTBObjSet("a" + currentTrigger, "left", leftPos);
tbfunction_pgTBObjSet("a" + currentTrigger, "top", 599);
tbfunction_pgTBObjSet("a" + currentTrigger, "width", myWidth);
tbfunction_pgStyleObject("a" + currentTrigger, "backgroundColor", "rgb(255, 255, 64)");
tbfunction_pgTBObjSet("startMarker", "visible", false);
// Update objectInfo collected for file (used by VB version)
var objectInfo = tbfunction_pgTBObjGet("limits","text");
var nextTrigger = currentTrigger + 1;
var objectLine = "R," + currentTrigger + "$" + nextTrigger + "," + leftPos + ",8805," + myWidth + ",755,,,60,62.5625,100";
// This may be the first object (this object may have 2 triggers when completed).
if (currentTrigger == 2)
{
objectInfo = objectLine; //No crlf required
}
else
{
objectInfo = objectInfo + "\n" + objectLine;
}
tbfunction_pgTBObjSet("limits", "text", objectInfo);
};
The strange thing is that if I only use 2 elements in triggers [] there is no problem. If I use 4, 1,2 and 4 are correct but 3 is always undefined. The result is:
2588,1,message 1,3269
5857,1,,,
undefined
13146,1,,,
The missing line would be something like "9252,1,second message,3894". The array seems to be updated momentarily but then the data immediately becomes undefined It seems that it is not possible to reliably update an array in the TB HTML from b.js. Why not? I suppose I could use an object property like text of field instead but this would mean rewriting all the code that uses triggers[] if I can find it. I can't search in the TB project because it's too full which makes life difficult. BTW I've posted this 3 times. The Forum keeps eating it!