gamerman2360 Posted October 27, 2005 Share Posted October 27, 2005 (edited) This gives you all the missing numbers from a list. I want to know if there is a better way to code this and also need to know what it would look like in javascript. I can't seem to find a StringTrimRight() in javascript . Clipput() is just something I added in for autoit. I know javascript can't do it. Basically I just want the javascript to return the other side of the list.$startinglist = StringSplit(InputBox("Numbers", "Please enter a list of all the numbers.", "2,6,9,12,18,22,23", " M"), ",") $topnum = $startinglist[$startinglist[0]] $list1 = "" $list2 = "" $endinglist = "" $compare = 1 For $i = 1 To UBound($startinglist) - 1 $list1 = $list1 & $i & ". " & $startinglist[$i] & @CRLF Next For $i = 1 To $topnum If $i = $startinglist[$compare] Then $compare = $compare + 1 Else $endinglist = $endinglist & $i & "," EndIf Next $endinglist = StringSplit(StringTrimRight($endinglist, 1), ",") For $i = 1 To UBound($endinglist) - 1 $list2 = $list2 & $i & ". " & $endinglist[$i] & @CRLF Next MsgBox(0, "Starting List", $list1) MsgBox(0, "Ending List", $list2) ClipPut("Starting List:" & @CRLF & $list1 & @CRLF & "Ending List:" & @CRLF & $list2) MsgBox(0, "Notice", "The list has been added to the clipboard!") Edited October 28, 2005 by gamerman2360 Link to comment Share on other sites More sharing options...
gamerman2360 Posted October 28, 2005 Author Share Posted October 28, 2005 (edited) Fine no one help . Made it myself ... <script type="text/javascript"> startinglist = prompt("Please enter a list of all the numbers.", "2,6,9,12,18,22,23").split(",") numlist = "" compare = 0 for (i = 1; i < startinglist[startinglist.length-1]; i++) { if (i == startinglist[compare]) { compare = compare + 1 } else { numlist = numlist + i + "," } } numlist = numlist.substring(0,numlist.length-1) document.write(numlist) </script> Edit: Took a while to learn javascript to make this. First javascript ever! Found lots of stuff that was not needed in the autoit one... Edited October 28, 2005 by gamerman2360 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now