How can I add a \url{} command to a .bst function. In this case, if the URL field is empty I want it to fill it with data from the DOI field, See the code below. I need to add this to the 4th line, but every way I have tried just causes it to crash.
FUNCTION {format.url}
{ is.use.url
    { url empty$
      {"[Online]. Available: https://doi.org/" doi * }
      { this.to.prev.status
        this.status.std
        cap.yes 'status.cap :=
        name.url.prefix " " *
        "\url{" * url * "}" *
        punct.no 'this.status.punct :=
        punct.period 'prev.status.punct :=
        space.normal 'this.status.space :=
        space.normal 'prev.status.space :=
        quote.no 'this.status.quote :=
      }
    if$
    }
    { "" }
  if$
}
This comes from IEEE.bst file and can be found around line 1920
                        
This is the code I developed to auto-fill the URL field from the DOI or arXiv number. All URLs are hyperlinked.
You must use
for the hyperlinks to work. Here is the code I made for the .bst file.