END expected error

38 views
Skip to first unread message

Tanya Esteves

unread,
May 29, 2024, 10:38:51 AMMay 29
to netlogo-users
I was using this code yesterday and was changing it elsewhere and it was working fine until I shut everything down. This morning, when resuming my work, Netlogo started giving me an END expected error for this procedure:

to calculate-emissions [car-turtle]
  let status [movement-status] of car-turtle
  let slope_1 [p-slope] of patch-here
  let speed_1 [speed] of car-turtle
  let car-type_1 [car-type] of car-turtle
  let distance-traveled_1 [distance-traveled] of car-turtle
  let emission 0
  foreach emission-data
  [ row ->
    if (item 0 row = status and
        check-slope (item 1 row) slope_1 and
        item 2 row = speed_1)
    [ set emission get-emission-for-type row car-type_1 ]
  ]
  ask car-turtle [ set emissions emission ]
end

I can't see anything wrong with it. Why would it suddenly start giving me this error when the same software, same version and same code worked fine yesterday?
Thanks

Steve Railsback

unread,
May 29, 2024, 2:06:11 PMMay 29
to netlogo-users
The error is very likely in the code you modified, not in this procedure. Occasionally, NetLogo's code checker is misleading about where an error is.

By the way, this statement:
`let slope_1 [p-slope] of patch-here`
is unnecessary because the turtle executing this procedure automatically can use patch variables of the patch it's on. You can just use `p-slope` instead of `slope_1`. Or... do you really want p-slope of the patch where car-turtle is? In that case, you want:
`let slope_1 [p-slope] of ([patch-here] of car-turtle)`

Tanya Esteves

unread,
Jun 4, 2024, 3:50:02 PMJun 4
to netlogo-users
Hi.
Sorry it took so long to get back. Sick kid...
Yes, I realized that the end in the previous procedure had a semicolon before it... such a silly mistake! Still a noobie and making my way through the netlogo world one tiny step at a time.
As for your suggestion for my calculate-emissions procedure, what I'm trying to do is get the agents to use an external .csv file to get emission values of the patch it is in, depending on the gradient, speed and agent type. So I think this means that I use p-slope elevation data from one patch to another to calculate if an agent is going uphill or downhill so it can check the .csv file for the correct entry. Apologies, because I'm not very fluent at this and take a looong time trying to understand some things. Considering what I previously explained and from what you suggested, I feel I need to use:
`let slope_1 [p-slope] of ([patch-here] of car-turtle)`
Am I correct? If so, I'll try to apply it to my code. Nothing like trying, right?
Thank you so  much for your kind reply and your suggestions.
Reply all
Reply to author
Forward
0 new messages