kopia lustrzana https://github.com/backface/turtlestitch
1 wiersz
5.4 KiB
XML
1 wiersz
5.4 KiB
XML
<blocks app="Snap! 4.2, http://snap.berkeley.edu" version="1"><block-definition s="substring of %'string' before %'marker'" type="reporter" category="operators"><comment w="175.33333333333334" collapsed="false">Reports the part of the first string up to the first instance of the second string inside it. If the second string isn't found, reports the entire first string.</comment><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%txt"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>string</l><l>marker</l></list><l>var world=this.parentThatIsA(IDE_Morph);
if (!("stringLibCaseIndependentComparison" in world)) {
 world["stringLibCaseIndependentComparison"] = true;
};
if (world["stringLibCaseIndependentComparison"]) {
 var index=string.toLocaleLowerCase().indexOf(marker.toLocaleLowerCase());
 if (index<0) {return string};
 return string.slice(0,index);
} else {
 var index=string.indexOf(marker);
 if (index<0) {return string};
 return string.slice(0,index);
}</l></block><list><block var="string"/><block var="marker"/></list></block></block></script></block-definition><block-definition s="substring of %'string' after %'marker'" type="reporter" category="operators"><comment w="203.33333333333334" collapsed="false">Reports the portion of the first input string starting after the first occurrence of the second string. If the second string isn't found in the first string, reports an empty string.</comment><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%txt"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>string</l><l>marker</l><l>markerlength</l></list><l>var world=this.parentThatIsA(IDE_Morph);
if (!("stringLibCaseIndependentComparison" in world)) {
 world["stringLibCaseIndependentComparison"] = true;
};
if (world["stringLibCaseIndependentComparison"]) {
 var index=string.toLocaleLowerCase().indexOf(marker.toLocaleLowerCase());
 if (index<0) {return ""};
 return string.slice(index+markerlength);
} else {
 var index=string.indexOf(marker);
 if (index<0) {return ""};
 return string.slice(index+markerlength);
}</l></block><list><block var="string"/><block var="marker"/><block s="reportStringSize"><block var="marker"/></block></list></block></block></script></block-definition><block-definition s="position of %'small' in %'large'" type="reporter" category="operators"><comment w="294" collapsed="false">Reports the character position (starting from 1) of the beginning of the first input string inside the second input string.
If it's not found, reports 0.</comment><header></header><code></code><translations></translations><inputs><input type="%s"></input><input type="%txt"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>sub</l><l>sup</l></list><l>var world=this.parentThatIsA(IDE_Morph);
if (!("stringLibCaseIndependentComparison" in world)) {
 world["stringLibCaseIndependentComparison"] = true;
};
if (world["stringLibCaseIndependentComparison"]) {
 return 1+sup.toLocaleLowerCase().indexOf(sub.toLocaleLowerCase());
} else {
 return 1+sup.indexOf(sub);
}</l></block><list><block var="small"/><block var="large"/></list></block></block></script></block-definition><block-definition s="use case-independent comparisons %'tf'" type="command" category="operators"><comment w="225.33333333333334" collapsed="false">If input is TRUE, comparisons made by functions in the string library will be case-independent (so "FOO" = "foo"). This is the default.
If input is FALSE, comparisons will be exact.</comment><header></header><code></code><translations></translations><inputs><input type="%b"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>flag</l></list><l>var world=this.parentThatIsA(IDE_Morph);
world['stringLibCaseIndependentComparison'] = flag;</l></block><list><block var="tf"/></list></block></script></block-definition><block-definition s="substring of %'str' from position %'start' to position %'end' inclusive" type="reporter" category="operators"><comment w="297.3333333333333" collapsed="false">Reports the portion of the first input (string) starting at the position given by the second input (counting from 1, like LETTER n OF) and ending at the position given by the third input (also counting from 1). If the third input is empty, reports the portion from the first position to the end of the string.
If a position number is negative, counts from the end backward, so -1 is the last character, -2 is the next to last, etc.</comment><header></header><code></code><translations></translations><inputs><input type="%txt"></input><input type="%n"></input><input type="%n"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>str</l><l>start</l><l>end</l></list><l>if (end != "") {
 return str.slice(start-1,end);
} else {
 return str.slice(start-1);
}</l></block><list><block var="str"/><block var="start"/><block var="end"/></list></block></block></script></block-definition></blocks> |