String expressions

edited February 2014 in Ruby Scripting
Hi Mattias-

I'm trying to get path out of a file name string.
I get error message "undefined method path".
What am I doing wrong?

Thanks, Itamar

module MyMacro

include RBA

@filename = 'c:\gds\test.txt'
@path = path(@filename)



  • edited February 2014

    Hi Itamar,

    I think what you are looking for is File.dirname:

    File.dirname("/home/matthias/somefile.txt") -> "/home/matthias"

    I think you mixed up "Expressions" with Ruby. "Expressions" are NOT Ruby. They are not scripts. Expressions are a low-level feature used inside KLayout for quick evaluation of numerical or conditional expressions. When you write scripts, you have to use Ruby features.


  • edited November -1
    Got it, Thanks much Matthias
Sign In or Register to comment.