Jump to content

Second Opinion Please?


Recommended Posts

Ok, in english:

Read from an INI. If it doesn't exist or the value is missing, ask the user for the number. Keep asking until the confirmation box is yes. If we get a yes, write the value to the INI file.

If we find the value we're looking for, skip the whole asking process....

CODE

$unum = IniRead("C:\Folder\ScanRte.ini", "ScanRte", "UserNumber", "NotFound")

If $unum = "NotFound" Then

Do

$unum = InputBox("User Number", "Please enter the number you use to route FAF to yourself", "U123456")

$box = MsgBox(36, $unum, "Is " & $unum & " correct?")

If $box = $no Then $unum = "NotFound"

Until $box = $yes

IniWrite(C:\Folder\ScanRte.ini", "ScanRte", "UserNumber", $unum)

EndIf

Thanks.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

It is ok. You can also use...

$yes = 6
$no = 7
$unum = IniRead("C:\Folder\ScanRte.ini", "ScanRte", "UserNumber", "NotFound")

If $unum = "NotFound" Then

   Do
      Do 
         $unum = InputBox("User Number", "Please enter the number you use to route FAF to yourself", "U123456")
      Until Not @error And $unum <> ''
      $box = MsgBox(36, $unum, "Is " & $unum & " correct?")
      If $box = $no Then $unum = "NotFound"
   Until $box = $yes

   IniWrite("C:\Folder\ScanRte.ini", "ScanRte", "UserNumber", $unum)

EndIf

For being even surer. The user cant avoid writing something.

(may happen in your version while user press cancel or leave the inputbox empty and press Yes just after)

Nice the [ codebox ] instead of the classic [ code ]

Edited by ezzetabi
Link to comment
Share on other sites

$yes = 6
$unum = IniRead("C:\Folder\ScanRte.ini", "ScanRte", "UserNumber", "NotFound")
If $unum = "NotFound" Then
   $unum = "U123456"
   Do
      $unum = InputBox("User Number", "Please enter the number you use to route FAF to yourself", $unum)
      If @error Then EXIT
      $box = MsgBox(36, "User Number", "Is " & $unum & " correct?")
   Until $box = $yes
   IniWrite("C:\Folder\ScanRte.ini", "ScanRte", "UserNumber", $unum)
EndIf

Link to comment
Share on other sites

$file = "C:\Folder\ScanRte.ini"

If FileExists ($file) = 1 then
    $unum = IniRead($file, "ScanRte", "UserNumber", "NotFound")
    Else
    Exit
EndIf

If $unum = "NotFound" Then
    Do
    $unum = InputBox("User Number", "Please enter the number you use to route FAF to    yourself", "U123456")
    $box = MsgBox(36, $unum, "Is " & $unum & " correct?")
    If $box = 7 Then 
        $unum = "NotFound"
    Until $box = 6
    IniWrite($file", "ScanRte", "UserNumber", $unum)
EndIf

qq

Link to comment
Share on other sites

It is ok. You can also use...

CODE

$yes = 6

$no = 7

$unum = IniRead("C:\Folder\ScanRte.ini", "ScanRte", "UserNumber", "NotFound")

If $unum = "NotFound" Then

  Do

      Do

        $unum = InputBox("User Number", "Please enter the number you use to route FAF to yourself", "U123456")

      Until Not @error And $unum <> ''

      $box = MsgBox(36, $unum, "Is " & $unum & " correct?")

      If $box = $no Then $unum = "NotFound"

  Until $box = $yes

  IniWrite("C:\Folder\ScanRte.ini", "ScanRte", "UserNumber", $unum)

EndIf

For being even surer. The user cant avoid writing something.

(may happen in your version while user press cancel or leave the inputbox empty and press Yes just after)

Nice the [ codebox ] instead of the classic [ code ]

<{POST_SNAPBACK}>

yeah, I prefer codebox, as it doesn't eat the whole screen and allows for scrolling left and right.

Anyway. Thanks, I also need add an error trap for the default value.... "U123456"

By the way, did you mean to make a doulbe "Do" statement?

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Yes, of course. It is meant for repeating the InputBox if the user press Cancel or write an empty string.

<{POST_SNAPBACK}>

My bad, I didn't see the other "until" statement. Need to wake up.....got any coffee?

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...