http://coldfusion.com logo
#cfml-general
Title
# cfml-general
g

gavinbaumanis

06/05/2022, 8:18 AM
if I define a variable in within a function - with "var"; Is it in the LOCAL or VARIABLES scope? Thanks!
p

pothys-mitrahsoft

06/05/2022, 9:36 AM
It is a function local scoped variable..
a

Adam Cameron

06/05/2022, 10:23 AM
@gavinbaumanis that would have been so easy to test for yourself, I wonder about the merits of asking it here.
Or... read the docs...
😄 1
m

mike42780

06/05/2022, 7:13 PM
var foo = bar; is the same as local.foo=bar;
👍 1
p

paolo79

06/21/2022, 9:17 AM
NB: LOCAL variables however cannot be used into closure functions
a

Adam Cameron

06/21/2022, 10:30 AM
Can you give an example of what you mean, @paolo79?
p

paolo79

06/23/2022, 11:05 AM
a function with this part:
Copy code
var shipUtils = createobject"component","shipUtils").init();

  local.q_orders = queryExecute('
      SELECT *
      FROM TABLE_ORDERS
      WHERE "_businessKey" = :businessKey
    ', {businessKey = {cfsqltype = "varchar", value = arguments.businessKey}});

  queryEach(local.q_orders, function(row, rowIndex, query) {
    local.q_ship = shipUtils.get(bordero = row.BORDERO);
  }
3 Views