Created
January 21, 2019 16:33
-
-
Save PeterBerthelsen/3e3b8214984d2c055125c1dcacd0889c to your computer and use it in GitHub Desktop.
OrthoThread Length Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////Length Check///////////////////////////////////////////////////// | |
try { //Attempt to check string value for parsing needs | |
if (stringToTweet == undefined) {throw "Undefined Value: 'stringToTweet'"}; //thrown when tweet string is undefined | |
var thread = stringToTweet.split(delim); //split initial string along provided delimeter | |
console.log("Input Thread Length: " + thread.length); //log number of strings in thread | |
} catch(e) { //Catch thrown error | |
console.log("Cannot Split Thread. Error: " + e); //Log error | |
} | |
try { //attempt to evaluate parsed tweet thread | |
if (thread == undefined) {throw "Undefined Value: 'thread'"}; //thrown when thread value doesn't exist | |
for (i in thread){ //for each string in thread... | |
if (thread[i].length == 0) {throw "Invalid Value: thread[" + i + "]"}; //thrown when thread has string error | |
console.log("Thread section characters: " + thread[i].length); //log string length | |
if (thread[i].length > twtMax){ //check thread[i] length | |
console.log("Cannot Tweet! Too long! Parsing..."); //if thread [i] too long for tweet, needs to be split | |
start = 0; //reset starting character for substring |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment