That example appears incomplete since the purpose is to find the 1st available partition number on that system for the partnew command. Can it be presented as recursive? Also, due to ISO files added and removed from a disk often due to updates etc, this new partition should be removed somehow automagically upon exiting the booted ISO or even as last Grub4DOS command in the same menu item. Otherwise many of such partitions can be later created at different times, and its unclear what if the user would want to create a REAL new partition on the same drive with Diskpart - what would happen? Its not unheard of even for USB thumbs that are by now exceeding 64-128GB limit.
The example maybe appears incomplete to you, but it does exactly what it is intended to do (and nothing more and nothing less, besides nothing else), i.e. check that the 4th (last) slot in a MBR partition table has a Partition ID of 0x00, and ONLY IF this Partition ID is 0x00, proceed to modify it, either re-setting it to all 00's or writiong a fake partition for a .iso file.
Unless it has changed in the (stupid) Windows 10, Diskpart will consider a slot in the partition table with Partition ID of 0x00 as empty or a non-partition, surely Windows as an OS does this.
Quick recap:
1) under windows a partition entry with partition ID 0x00 is a non-partition
2) under Linux a partition entry with partition ID 0x00 is a partition IF the LBA and/or CHS data is valid
By running any number of times:
partnew (hd0,3) 0 0 0
and/or
partnew (hd0,3) 0 /<whatever.iso>
in whatever order/sequence you like, the partition ID will always remain 0x00, and as such it will be ignored by windows and mapped by Linux (only if the last command is the second one, otherwise it will be a completely empty entry).
In any case you need to explicitly chainload that partition at boot time (via grub4dos or similar) as it is -by design - not an active one if you wanto to boot from the .iso mapped to it.
Wonko