As far as I can understand, you want to create a program with the name stored in the OS variable Str4 and the contents stored in the OS variable Str1? If so, here's what I've come up with. I made two different versions: one is larger and allows you to handle each error that could occur individually, while the other is smaller and doesn't support error handling (errors are still caught and avoided, they just cannot be acted upon). The source for both versions is included as text below and as programs attached at the bottom of this post.
With error handling:
!If GetCalc("Str1")→S
.Str1 not found
Else
!If GetCalc("Str4")→N
.Str4 not found
Else
.L₁ can be replaced with any section of safe RAM at least 9 bytes large
'prgm'→{L₁}ʳ
Fill(L₁+1,8)
Copy(N,L₁+1,{N-2}ʳ)
!If GetCalc(L₁,{S-2}ʳ→L)→P
.Creation error
Else
Copy(S,P,L)
End
End
End
Without error handling:
If GetCalc("Str4")→N
.L₁ can be replaced with any section of safe RAM at least 9 bytes large
'prgm'→{L₁}ʳ
Fill(L₁+1,8)
Copy(N,L₁+1,{N-2}ʳ)
If GetCalc("Str1")→S
Copy(S,GetCalc(L₁,{S-2}ʳ→L),L)
End
End