
// Script function: Compute mean free path and average electron energy loss
// Requirement: With or without multiple images opened

// Unless named starting with GlobalSino, EM, My, Self, the function commands are defined 
//by Gatan DM, please see at link: http://www.globalsino.com/EM/page2597.html

TagGroup GlobalSino, EMItems
GlobalSino = DLGCreateDialog( "Please enter your numbers:", EMItems )

TagGroup MyNumber1, MyNumber2, MyNumber3, MyNumber4, MyNumber5

EMItems.DLGAddElement( DLGCreateRealField( "Voltage (keV) :", MyNumber1, 200, 8, 8 ) )      
EMItems.DLGAddElement( DLGCreateRealField( "Atomic number  :", MyNumber2, 14, 8, 8 ) )      
EMItems.DLGAddElement( DLGCreateRealField( "Beta (mrad) :", MyNumber3, 5, 8, 8 ) )      

if ( !Alloc( UIframe ).Init( GlobalSino ).Pose() ) exit (0)

number lamda, F, Em

number E0 = MyNumber1.DLGGetValue()
number Z = MyNumber2.DLGGetValue()
number beta = MyNumber3.DLGGetValue()

Em = 7.6*(Z**0.36)

F = (1+(E0/1022))/( (1+(E0/511) )**2)
lamda=106*F*E0/(Em*log(2*beta*E0/Em))
Result ("Lamda = " + lamda + " nm \n")
Result ("Average electron energy loss = " + Em + " eV\n")