Sign in to follow this  
Followers 0
gamerman2360

Numbers

2 posts in this topic

#1 ·  Posted (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 B). 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 by gamerman2360

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Fine no one help :o. Made it myself B)...

<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 by gamerman2360

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0