| User Creation Crash. 
 
	 
	
		| Author | Message |   
		| Balmung 
 
  
 
 
 | 
			
				|  Posted: Wed May 16, 2007 8:26 am    Post subject: User Creation Crash. |  |   
				| 
 |  
				| I am having a problem creating a user, when it asks for the user if it already exsists and they try to make that user again it crashes >_< can i get some help? 
 
 	  | code: |  	  | 
procedure create
 var name : string
 var password : string
 var sn1 : int
 var sure : string
 
 put "Enter Username: " ..
 get name
 put "Enter Password: " ..
 get password
 if File.Exists ("users/" + name + ".ini") then %% cheaks if user exsists
 put "User Exsists"
 loop  %% If user Exsists Ask for a New User
 put "Enter Username: " ..
 get name
 put "Enter Password: " ..
 get password
 put "Are you sure? " ..
 get sure
 loop
 if sure = "Yes" or sure = "yes" then %% If yes then create
 if File.Exists ("users/" + name + ".ini") then %% cheaks if user exsists
 put "User Exsists"
 exit
 elsif File.Exists ("users/" + name + ".ini") = false then
 open : sn1, "users/" + name + ".ini", put
 put : sn1, name, " ", password
 put "User Created"
 exit
 elsif sure = "No" or sure = "no" then %% If No Go Back
 cls
 exit
 end if
 end if
 end loop
 if File.Exists ("users/" + name + ".ini") then
 exit
 end if
 end loop
 else
 open : sn1, "users/" + name + ".ini", put     %%Creates User Name
 put : sn1, name, " ", password
 put "User Created"
 delay (1000)
 end if
 close : sn1
 end create
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| d2bb 
 
 
 
 
 | 
			
				|  Posted: Wed May 16, 2007 11:03 am    Post subject: RE:User Creation Crash. |  |   
				| 
 |  
				| try using a boolen. 
 
 so if user1 = true
 
 Code:
 
 
 User1 =true
 if user1=true then
 put " enter another name"
 else user1=false then
 put "Your user has been made"
 end if.
 
 
 
 just a thought. may or may not work with ur code.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| DIIST 
 
  
 
 
 | 
			
				|  Posted: Wed May 16, 2007 5:10 pm    Post subject: Re: User Creation Crash. |  |   
				| 
 |  
				| All that could have been simplified too: 
 	  | Turing: |  	  | /**
n-name
 p-pasword
 retruns true if succesfull, false if failed
 */
function
  createUser ( n, p : string) : boolean
    if File.Exists ("users/"  + n + ".ini") then
        result false
    end if
    var  stream : int
    open :  stream, "users/"  + n + ".ini", put
    put :  stream, n, " ",  p
    result true
end  createUser
/** Main Program
 ***/
var
  name, password : string := ""
loop
    put "Enter Username: " . .
    get  name
    put "Enter Password: " . .
    get  password
    exit when  createUser ( name, password)
    put "All ready exists, please enter another one"
end loop | 
 
 As for the error i think it was just that when you close the snl it should be inside the if where it is open not outside. Hope this helps
 
   
 lilmizeminem you shouldn't be spamming
  |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Balmung 
 
  
 
 
 | 
			
				|  Posted: Thu May 17, 2007 7:49 am    Post subject: RE:User Creation Crash. |  |   
				| 
 |  
				| Thanks ^^ |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |