The dv.view() is for passing parameters into another script which is then executed in the Dataview context. Like @holroy said, variables defined there aren’t visible to the calling script.
What you can do though, is define functions in a reusable script, and then use the return values from those functions. You can see a working example of that here: