This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Updating a script
#1
Hi, 
I have would like to dynamically update a script from another script (so update an event handler script from a library as part of version control )

I've tried this:

-- Version 1.0.7 Added function
function addOrUpdateECGEventScript( data ) -- data is a table with the various script properties defined.

-- check for duplicate script with the same name
exists = script.get( data.name )
if exists ~= nil then
  log( data.name, 'Script exists, updating' )
  data.id = exists.id -- get the scripting id
  db:update( 'scripting', data )
else
  log( data.name, 'Script does not exist' )   
  db:insert( 'scripting', data )
  data.id = db:getlastautoid()
end 

script.save( data, true )
script.reloadsingle( data )
end

And whilst it does not generate any errors in the Error Log, it doesn't update the Scripting -> Event Based view. 
Is what I am trying to achieve possible (the idea is that the library will ensure that the event handler is up to date)?
If so, what am I doing wrong? Is it the true parameter in the script.save?

Regards

Dave

Not to bother, I fixed it by specifying a where clause in my update

db:update( 'scripting', data, { id = exists.id } )

Thanks
Reply


Messages In This Thread
Updating a script - by dave.bolas@se.com - 19.01.2023, 11:45

Forum Jump: