Arm debugger script

I am looking for more example to write arm debugger script. specifically on using the keyword while, newvar, if etc.

How to read some register and get the value in variable to that can be used in while/if statement?