You could construct an array of what the pitch class intervals should be for harmonic minor:
#(0 2 3 5 7 8 11)
then use (!KeyNumber mod: 12) to index into that array,
(!KeyNumber mod: 12) of: #(0 2 3 5 7 8 11)
Then add the tonic and the octave to that interval for the Frequency field:
!Tonic nn + (((!KeyNumber - !Tonic) mod: 12) of: #(0 2 3 5 7 8 11)) nn + ((!KeyNumber - !Tonic) // 12 * 12) nn
Does this do what you had in mind?