Jump to content

Script doesn't continue with next user


Recommended Posts

Hi all,

I have this script (this is it partially) in which I try to do the same actions for different users. To make it easy for myself I created a .ini file in which I stored the usernames and the corresponding passwords. I want the script to automatically go to the next user. The problem is that it doesn't. It only uses the username and password of the last user and doesn't go further with the others. Does any of you have a clue why?

This is the part of the script:

Global $NumberOfUsers = IniRead ( '.\bankusers.ini', 'MobHeader', 'NumberOfUsers', 1)
Global $UserNumber = IniRead ( '.\bankusers.ini', 'MobHeader', 'NumberOfUsers', 1 )
Global $MobUser = IniRead ( '.\bankusers.ini', 'User' & $UserNumber, 'MobUser', "Unknown User" )
Global $MobPass = IniRead ( '.\bankusers.ini', 'User' & $UserNumber, 'MobPass', "" )


Func _GetNextUser()
$UserNumber = $NumberOfUsers + 1
if $UserNumber > $NumberOfUsers Then
$UserNumber = 1
EndIf
EndFunc

This is the .ini file:

[MobHeader]

NumberOfUsers=3

;If NumberOfUser is less than the number of User Sections
;then only the user sections up to the number will be actioned
;If NumberOfUser is More than the number of User Sections
;then and Error will occur switiching users
;

[User1]

MobUser=monkey1
MobPass=raaar

[User2]

MobUser=monkey2
MobPass=sheep

[User3]

MobUser=monkey3
MobPass=trees

I hope you guys can help me out.

Berend Jan

Link to comment
Share on other sites

These 2 lines are doing the same thing.

Global $NumberOfUsers = IniRead ( '.\bankusers.ini', 'MobHeader', 'NumberOfUsers', 1)
Global $UserNumber = IniRead ( '.\bankusers.ini', 'MobHeader', 'NumberOfUsers', 1)

You might want to look at INIReadSection() in the help file, but for now try this.

Global $NumberOfUsers = IniRead ( '.\bankusers.ini', 'MobHeader', 'NumberOfUsers', 1)

Func _GetNextUser()
   For $I = 1 To $NumberOfUsers;Will loop 3 times, once for each user
      $MobUser = IniRead ( '.\bankusers.ini', 'User' & $I, 'MobUser', "Unknown User" )
      $MobPass = IniRead ( '.\bankusers.ini', 'User' & $I, 'MobPass', "" )
      MsgBox(4096, "", "User: " & $MobUser & @CRLF & "Pass: " & $MobPass)
   Next
EndFunc
Edited by Burrup

qq

Link to comment
Share on other sites

These 2 lines are doing the same thing.

Global $NumberOfUsers = IniRead ( '.\bankusers.ini', 'MobHeader', 'NumberOfUsers', 1)
Global $UserNumber = IniRead ( '.\bankusers.ini', 'MobHeader', 'NumberOfUsers', 1)

You might want to look at INIReadSection() in the help file, but for now try this.

Global $NumberOfUsers = IniRead ( '.\bankusers.ini', 'MobHeader', 'NumberOfUsers', 1)

Func _GetNextUser()
   For $I = 1 To $NumberOfUsers;Will loop 3 times, once for each user
      $MobUser = IniRead ( '.\bankusers.ini', 'User' & $I, 'MobUser', "Unknown User" )
      $MobPass = IniRead ( '.\bankusers.ini', 'User' & $I, 'MobPass', "" )
      MsgBox(4096, "", "User: " & $MobUser & @CRLF & "Pass: " & $MobPass)
   Next
EndFunc

<{POST_SNAPBACK}>

no this doesn't work either:S very strange. it's like he doesn't read the ini file.
Link to comment
Share on other sites

That means that the INI file is different then you provided. I tested my example with this.

[MobHeader]

NumberOfUsers=3

[User1]

MobUser=monkey1
MobPass=raaar

[User2]

MobUser=monkey2
MobPass=sheep

[User3]

MobUser=monkey3
MobPass=trees

qq

Link to comment
Share on other sites

That means that the INI file is different then you provided. I tested my example with this.

[MobHeader]

NumberOfUsers=3

[User1]

MobUser=monkey1
MobPass=raaar

[User2]

MobUser=monkey2
MobPass=sheep

[User3]

MobUser=monkey3
MobPass=trees

<{POST_SNAPBACK}>

hmm.. strange. ok he does read the users and passwords now. but what he doesn't do is doing the actions it should do. it just loops until it reaches the last user and then does the action but only on that user. He should be doing it one by one.
Link to comment
Share on other sites

hmm.. strange. ok he does read the users and passwords now. but what he doesn't do is doing the actions it should do. it just loops until it reaches the last user and then does the action but only on that user. He should be doing it one by one.

<{POST_SNAPBACK}>

"He"????

I used a message box as the output, just change the message box to whatever you want to do for each user.

Edited by Burrup

qq

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...