Need a bit Help with the Function

I am completely new in the field of programming Python and Ignition Scripting.
I have a piece of code that I am trying to understand.
Please help me out if you can,
address = “”
def getSLCFile( address ):
end_char = address.index(’:’)
return address[:end_char]

What will be the return value ?

Nothing at all. You aren’t calling getSLCFile() anywhere, just defining it.

I have the similar function,
def getSLCWord( address ) :
end_char = address.index(’:’)
return int(address[end_char+1:])

and I am calling it as ,
start_address = “”
start_word = getSLCWord(start_address)

What will be the value of start_word ??

You should get a ValueError, since the colon isn’t in the string passed to your function. See this documentation for string methods in jython.
Also, please edit your posts to format your code. Use triple backquotes on separate lines above and below a code block to make it format neatly. It is hard to follow python code when the indentation isn’t visible.

1 Like