none
What's wrong with my code? RRS feed

  • Question

  • Here's my code, it'll give error.

    x = Math.GetRandomNumber(99999)
    y = Math.GetRandomNumber(99999)
    z = x*y
    TextWindow.Title = z
    x = File.CreateDirectory("C:\Users\Desktop\RandomNumber\RandomNumber.txt")
    If x = "FAILED" Then
      TextWindow.ForegroundColor = "red"
      TextWindow.WriteLine("Couldn't create the directory. Aborting...")
      TextWindow.Pause()
      Program.End()
      Else
        
        x = File.WriteLine("C:\Users\Desktop\RandomNumber\RandomNumber.txt", "1", "The random number has been generated using PetaHD's tool, here is the random number sir:")
    If x = "FAILED" Then
      TextWindow.ForegroundColor = "red"
      TextWindow.WriteLine("Couldn't write the line 1 to the created txt directory. Aborting...")
      TextWindow.Pause()
      Program.End()
      Else
      
      x = File.WriteLine("C:\Users\Desktop\RandomNumber\RandomNumber.txt", "2", z)
      If x = "FAILED" Then
      TextWindow.ForegroundColor = "red"
      TextWindow.WriteLine("Couldn't write the line 1 to the created txt directory. Aborting...")
      TextWindow.Pause()
      Program.End()
      Else
      x = File.WriteLine("C:\Users\Desktop\RandomNumber\RandomNumber.txt", "3", "The random number 1: " + x + "and the random number 2: " + y + " has been multiplicationned to make the" + z )
      If x = "FAILED" Then
      TextWindow.ForegroundColor = "red"
      TextWindow.WriteLine("Couldn't write the line 1 to the created txt directory. Aborting...")
      TextWindow.Pause()
      Program.End()
      Else
      x = File.WriteLine("C:\Users\Desktop\RandomNumber\RandomNumber.txt", "4", "You can contact using Discord, PetaHD#6693 and thanks for using it.")
      If x = "FAILED" Then
      TextWindow.ForegroundColor = "red"
      TextWindow.WriteLine("Couldn't write the line 1 to the created txt directory. Aborting...")
      TextWindow.Pause()
      Program.End()
    ElseIf x = "SUCCESS" Then 
      TextWindow.ForegroundColor = "green"
      TextWindow.WriteLine("Output folder: C:\Users\Desktop\RandomNumber\RandomNumber.txt")
      TextWindow.WriteLine("By PetaHD, open the txt for contact info...")
    EndIf
    EndIf
    EndIf
    EndIf
    EndIf
    'What's wrong with the following code and always-online contact:
    'Discord: PetaHD#6693

    Wednesday, December 6, 2017 5:30 PM

Answers

  • Your %USERNAME% is missing in the paths and folder path for 'File.CreateDirectory' is wrong.

    Try this, and first add your UserName in the first line:

    name = "YourNameHERE"         ' !!!!!!  eg. name = "LAMGE2"  or  name = LDFile.UserName
    x = Math.GetRandomNumber(99999)
    y = Math.GetRandomNumber(99999)
    z = x*y
    TextWindow.Title = z
    x = File.CreateDirectory("C:\Users\"+ name +"\Desktop\RandomNumber")

    If x = "FAILED" Then
      TextWindow.ForegroundColor = "red"
      TextWindow.WriteLine("Couldn't create the directory. Aborting...")
      TextWindow.Pause()
      Program.End()
    Else
      x = File.WriteLine("C:\Users\"+ name +"\Desktop\RandomNumber\RandomNumber.txt", "1", "The random number has been generated using PetaHD's tool, here is the random number sir:")
      If x = "FAILED" Then
        TextWindow.ForegroundColor = "red"
        TextWindow.WriteLine("Couldn't write the line 1 to the created txt directory. Aborting...")
        TextWindow.Pause()
        Program.End()
      Else
        x = File.WriteLine("C:\Users\"+ name +"\Desktop\RandomNumber\RandomNumber.txt", "2", z)
        If x = "FAILED" Then
          TextWindow.ForegroundColor = "red"
          TextWindow.WriteLine("Couldn't write the line 1 to the created txt directory. Aborting...")
          TextWindow.Pause()
          Program.End()
        Else
          x = File.WriteLine("C:\Users\"+ name +"\Desktop\RandomNumber\RandomNumber.txt", "3", "The random number 1: " + x + "and the random number 2: " + y + " has been multiplicationned to make the" + z )
          If x = "FAILED" Then
            TextWindow.ForegroundColor = "red"
            TextWindow.WriteLine("Couldn't write the line 1 to the created txt directory. Aborting...")
            TextWindow.Pause()
            Program.End()
          Else
            x = File.WriteLine("C:\Users\"+ name +"\Desktop\RandomNumber\RandomNumber.txt", "4", "You can contact using Discord, PetaHD#6693 and thanks for using it.")
            If x = "FAILED" Then
              TextWindow.ForegroundColor = "red"
              TextWindow.WriteLine("Couldn't write the line 1 to the created txt directory. Aborting...")
              TextWindow.Pause()
              Program.End()
            ElseIf x = "SUCCESS" Then
              TextWindow.ForegroundColor = "green"
              TextWindow.WriteLine("Output folder: C:\Users\"+ name +"\Desktop\RandomNumber\RandomNumber.txt")
              TextWindow.WriteLine("By PetaHD, open the txt for contact info...")
            EndIf
          EndIf
        EndIf
      EndIf
    EndIf



    Wednesday, December 6, 2017 6:08 PM
    Answerer