Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save steveosoule/42db4f93e2fe64e9d94d6bb8428e6041 to your computer and use it in GitHub Desktop.

Select an option

Save steveosoule/42db4f93e2fe64e9d94d6bb8428e6041 to your computer and use it in GitHub Desktop.
Miva / MVT: Use s.null for Null Values

Use s.null For Unused Return Values

MivaScript 5.36 added support for s.null. s.null will always be null. Assigning a value to s.null does not change the value of s.null and avoids keeping the result of a function or expression in memory.

You can assign variables to s.null when you do not need to use the return variable for anything. By assigning variables to s.null, it more clearly indicates that the variable will not be used (as opposed to l.result or l.success). Just be sure you do not pass s.null (or variables assign to s.null by reference) into MivaScript or mvt:do functions

Incorrect

<mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_Code( 'test', l.product )" />	
<mvt:assign name="NULL" value="miva_array_insert(l.foo, 'Foobar', -1)" />	

Correct

<mvt:do file="g.Module_Library_DB" name="s.null" value="Product_Load_Code( 'test', l.product )" />	
<mvt:assign name="s.null" value="miva_array_insert(l.foo, 'Foobar', -1)" />	
mvt:eval s.null=<mvt:eval expr="s.null" />
<br>
mvt:assign s.null=1<mvt:assign name="s.null" value="1" />
<br>
mvt:eval s.null=<mvt:eval expr="s.null" />
mvt:eval s.null=
mvt:assign s.null=1
mvt:eval s.null=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment