Bug 330 : Not a bug. Just a quick addition to insertFrame
Last modified: 2006-04-25 13:54




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
enhancement

 

Reporter:
scloopy
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2006-04-23 17:27
Hey I just ran into a situation where this function would be really useful
so I made it a little bit more general so you can use any number instead of
just the frameCount. Is this the right place to post changes like this?

ryan

/**
* Check a string for #### signs to see if the frame number should be
* inserted. Used for functions like saveFrame() and beginRecord() to
* replace the # marks with the frame number. If only one # is used,
* it will be ignored, under the assumption that it's probably not
* intended to be the frame number.
*/
public String insertFrame(String what) {
return insertFrame(what, frameCount);
}

public String insertFrame(String what, int frameNum) {
int first = what.indexOf('#');
int last = what.lastIndexOf('#');

if ((first != -1) && (last - first > 0)) {
String prefix = what.substring(0, first);
int count = last - first + 1;
String suffix = what.substring(last + 1);
return prefix + nf(frameNum, count) + suffix;
}
return what; // no change
}
Additional Comment #1 From fry 2006-04-25 13:54
prolly best to post on processinghacks.