Not sure exactly what you mean by “wrong code” but I would say that you need a G90 on the the G01 Z-50. Line
If you follow the loop through, the last command is G91 X-2 so when you loop back to G01 Z-50 this will be an incremental move and would only actually move to Z-48 as you are at Z2 when you execute that line.
Hope that helps.
My bad. I assumed you got an alarm when you tried to load that code into the machine. If this is the case, what is the exact alarm?
One other thing, on the Haas lathe, G90 is NOT "Absolute", it's a turning cycle command. And G91 is NOT "Incremental"... use X and Z for absolute commands, and use U and W for incremental commands.
I read my instruction today and there is nothing about parameter 57:22 I found: https://diy.haascnc.com/printpdf/reference-docs/macro-programming-information How to set this parameter to 1? I'm a beginner.
I'm not 100% sure on this, but I believe you can turn the option on for a trial (100 hours?), but it'll revert to off after the trial expires.
You need to turn Setting 7 Parameter Lock OFF, then go to Parameter 57 bit 22 and change it to 1, then change Setting 7 back to 1 to lock the parameters again.
It's been a while since I've pretended to be a Haas expert, though, so you might want to contact your HFO to be sure.