# Difference between assigning var in writer vs createGlobalVariable?

**URL:** <https://forum.universal-robots.com/t/difference-between-assigning-var-in-writer-vs-createglobalvariable/22561>\
**Category:** URCap Development\
**Created:** [July 10, 2022, 1:27am UTC](https://forum.universal-robots.com/t/difference-between-assigning-var-in-writer-vs-createglobalvariable/22561 "2022-07-10T01:27:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![roguebuck](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/roguebuck/32/4848_2.png) [@roguebuck](https://forum.universal-robots.com/u/roguebuck)\
**Post date:** [July 10, 2022, 1:27am UTC](https://forum.universal-robots.com/t/difference-between-assigning-var-in-writer-vs-createglobalvariable/22561/1 "2022-07-10T01:27:46Z")

</div>

Hi all,

Can someone please help me understand when & why you might use the methods outlined in “Working with Variables.pdf” instead of just assigning the variable using a writer.appendLine()?

It seems like the variable has to be initialized with `writer.appendLine("global var=somedata")` to avoid the ol’ “name is not defined” problem at compile.

…so why not just use `writer.appendLine("var=someotherdata")` when we need to change the variable?

seems like the expressionbuilder-variableFactory-createGlobalVariable-undoredo-undoablechanges-datamodel.set() thing is WAY more keystrokes than appendLine…but I must be missing the value of it…

someone please set me straight?
