Re: Function initialization at the first call.

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...
SnakeCharmer said...

For example, I need function for exctraction of values from some sequence. This sequence must be builded before any extractions (for example, filled with random data). How to do such initialization? I thought up only one way yet.

More or less...in 4.0 you can also use object() to determine if a variable has been initialized:

 
sequence String 
 
function InitString() 
  String = "I'm initialized now!" 
end function 
 
export function SymbolFromString(integer Position) 
  if not object(String) = 0 then InitString() end if 
  return String[Position] 
end function 

Matt

Err ... shouldn't that be

if object(String) = 0 then 

or

if not object(String) then 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu