Author Topic: Diesel question  (Read 3679 times)

0 Members and 1 Guest are viewing this topic.

Martin-Y

  • Guest
Diesel question
« on: June 02, 2004, 10:37:59 AM »
Could anyone explain the role of the numbers in the following, I'm OK with the words as it seems to return part of a string but thats the limit of my knowledge. I have been unable to find an explanation in any tutorials.
code:
$(upper,$(substr, $(getvar, "dwgprefix")$(getvar, "dwgname"), $(+, 5, $(*, 16, $(eq, $(substr, $(getvar, "dwgprefix"), 7, 1), "-")))))

SpeedCAD

  • Guest
Diesel question
« Reply #1 on: June 02, 2004, 11:03:06 AM »
Hi...

What thing you not understand??

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Diesel question
« Reply #2 on: June 02, 2004, 11:05:52 AM »
Returns the substring of string, starting at character start and extending for length characters.

$(substr, string, start [, length])
Characters in the string are numbered from 1. If length is omitted, it returns the entire remaining length of the string.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Martin-Y

  • Guest
Diesel question
« Reply #3 on: June 02, 2004, 11:15:32 AM »
I understand it must control the length of the string but I'm being a bit thick as regards the formula (+ 5(* 16) 7, 1) what is it doing?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Diesel question
« Reply #4 on: June 02, 2004, 11:37:46 AM »
It's a LONG time since I've played with Diesel, so this is an old memory ::

(getvar "dwgname")   ;;--> "Drawing1.dwg"
(getvar "dwgprefix")  ;;--> "J:\\CONS\\"

(substr (getvar "dwgprefix") 7  1) ;;-- > "S"

(eq (substr (getvar "dwgprefix") 7 1) "-")  ;; is it equal to "-" ??
;;If the strings are identical, the $(eq ... returns 1; otherwise, it returns 0.

;; so :

(+, 5, $(*, 16, $(eq, $(substr, $(getvar, "dwgprefix"), 7, 1), "-")))))

will return either

(+ 5 ( * 16 0)) ;;--> 5
or
(+ 5 ( * 16 1)) ;;--> 21
So the Diesel expression will return a string,
converted to uppercase, the concatenation of path an drawing name, stripped to either char 5 or 21.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Martin-Y

  • Guest
Diesel question
« Reply #5 on: June 02, 2004, 12:09:56 PM »
Kerry

Thanks for your patience, I have had a play and shortened it to
code:
$(upper,$(substr, $(getvar, "dwgprefix")$(getvar, "dwgname"), 5))

at least I understand this strips to the 5th character, could not get my head round the need for *16 and 7, 1

Thank you

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Diesel question
« Reply #6 on: June 02, 2004, 12:26:14 PM »
Soungs to me as if the original was designed to suit a VERY regimented file and folder naming convention.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.