EnterPin Code - Password Problem

Hi Folks,

may you can bring some light into the darkness… :slight_smile:

In my application I have to check the pincode of the simcard - this will be done by:

set xstr to "at+CPIN?" & return
serialport write xstr to portRef
delay 1

set pin_card to serialport read portRef
display dialog pin_card
delay 1

Now I am checking the result - if the result is “SIM PIN” then there must be a password entered - the Simcard is locked:

if pin_card contains "SIM PIN" then
	show window "pin"
	repeat
		try 
			if pin_get is false then exit repeat
		end try
	end repeat
	hide window "pin"
end if

I have put a text field “txt_pin” and a button “bt_pin” on my window “pin” - to check wheter the pincode is correct I made the onclick handler

if name of theObject is "bt_pin" then
	repeat
		try
			tell current application
				set theAnswer to contents of text field "txt_pin" of window "pin"
				set xstr to "at+CPIN= " & theAnswer & return
				delay 1
				set pin_read to serialport read portRef
				delay 1

 				if pin_read does not contain "ERROR" then
					set pin_get to false
					exit repeat
				end if
			end tell
		end try
	end repeat
end if

The Problem:

I am not able to press bt_pin and not able to delete a previous entered code in txt_msg… I know I just can give you small informations, but maybe I made an error in this construct…

Thanks for your help…

Stefan

Hi Folks,

I have found out, that I have to make the window active before I am able to enter my commands:

I try this with


show window "pin"
call method "enableFlushWindow" of window "pin"


I get a NSInternalScriptError (8) - by clicking on OK I am able to enter my data… but I don´t think that I am on the correct way, because when I enter the password wrong, then the repeat will not wait to start after I have entered the new password…

Best Regards,

Stefan

Hi Folks,

what I have found out now is, that even if


set pin_get to false 

I am not able to jump back to the section where I opened the window “pin” to exit the repeat there…

How can I jump in the script?

Thanks for your help,

Stefan