Precise magnetic control of the supercurrent and fluxoids in nanodevices: Memory effects and diode effects