Author Topic: Lisp compatibility with 2007  (Read 3999 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Lisp compatibility with 2007
« on: October 27, 2006, 01:06:20 AM »
Can anyone tell me why this lisp routine does not work in 2007? It always worked in 2006-
I think the problem is with the vla-getremotefile statement.

Thanks a ton

Code: [Select]
;command sct arg stock symbol
;example sct dyn
(defun c:sct ( / $factor $log cnt1 cnt1f e ml strstocktickersymbol)
  (setvar "cmdecho" 0)
  (setvar "osmode" 0)
  (setq strStockTickerSymbol (getstring "Enter Ticker Symbol: "))
  (setq ml (GetStockchart strStockTickerSymbol))
  (setq ml (vl-remove (assoc "Date" ml) ml))
  (setq $log (atof (nth 1 (nth 0 ml))))
  (setq $factor 1)
  (setq cnt1 0)
  (foreach e ml
    (setq cnt1f 0.05);(* 0.0075 (* $factor (atof (nth 1 e)))))
    (vl-cmdf "line" (list (- cnt1 0.02) (* $factor (atof (nth 1 e)))) (list cnt1 (* $factor (atof (nth 1 e)))) "")
    (vl-cmdf "line" (list cnt1 (* $factor (atof (nth 2 e)))) (list cnt1 (* $factor (atof (nth 3 e)))) "")
    (vl-cmdf "line" (list cnt1 (* $factor (atof (nth 4 e)))) (list (+ cnt1 0.02) (* $factor (atof (nth 4 e)))) "")
    (setq cnt1 (+ cnt1 cnt1f))
  )
  (setvar "osmode" 191)
  (princ)
)
(defun GetStockchart (ticker / acad d date dl doc ey file fno line m sy util)
  (setq acad (vlax-get-acad-object)
doc (vla-get-activedocument acad)
util (vla-get-utility doc)
date (Today-Date)
m (itoa (- (nth 0 Date) 1))
d (itoa (nth 1 Date))
sy (itoa (- (nth 2 Date) 1))
ey (itoa (nth 2 Date))
dl '()
  )
  (vla-getremotefile util (strcat "http://ichart.finance.yahoo.com/table.csv?s=" ticker "&a=" m "&b=" d "&c=" sy "&d=" m "&e=" d
  "&f=" ey "&g=d&ignore=.csv"
  ) 'file actrue
  )
  (setq FNO (open file "r"))
  (while (setq Line (read-line FNO))
    (progn
      (setq line (dm:parse "," line))
      (setq dl (append
(list line)
dl
       )
      )
    )
  )
  (close FNO)
  (vl-file-delete file)
  dl
)
(defun RemoveBadChar (l / e nono)
  (if l
    (progn
      (setq nono '(34 44 39 92 47))
      (foreach e l
(if (member e nono)
  (setq l (vl-remove e l))
)
      )
    )
  )
  l
)

(defun dm:parse (delim string / count lis strStack)
  (setq strStack ""
count (strlen string)
lis nil
  )
  (while (> count 0)
    (if (= delim (substr string count 1))
      (setq lis (cons strStack lis)
    strStack ""
      )
      (setq strStack (strcat (substr string count 1) strStack))
    )
    (setq count (1- count))
  )
  (if (= "" strStack)
    lis
    (cons strStack lis)
  )
)
(defun Today-Date (/ S L)
  (setq S (rtos (getvar "CDATE") 2 0)
L (strlen S)
S (list (atoi (substr S (- L 3) 2)) (atoi (substr S (- L 1) 2)) (atoi (substr S 1 (- L 4))))
  )
)


MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: Lisp compatibility with 2007
« Reply #1 on: October 27, 2006, 01:16:38 AM »
cool idea, I never thought of trying that with acad, can't wait to see what it does (lisp is all greek to me :) ).
In 2006 I get:
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Lisp compatibility with 2007
« Reply #2 on: October 27, 2006, 01:26:21 AM »
I still need to work the math on stocks with a high price like goog :oops: , but here is an ouput for a cheapie like dyn
« Last Edit: October 27, 2006, 01:52:06 AM by Danielm103 »

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: Lisp compatibility with 2007
« Reply #3 on: October 27, 2006, 01:48:55 AM »
nice! I tried it with dyn too, maybe something to do with units or something.

now all you need is some bolinger bands...ooh, and candlsticks would be nice :D
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Lisp compatibility with 2007
« Reply #4 on: October 27, 2006, 02:13:48 AM »
It could be! I have my units set to Decimal. It works on my machine here and at work
(Don’t tell my boss). I guess it has bigger issues  :cry:

Hehe. You must be one of those speculators too  :-D. Oh yes I want to add all the technical charting tools, If I could only make it tell me when to buy and sell 

Dan

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lisp compatibility with 2007
« Reply #5 on: October 27, 2006, 07:49:14 AM »
You are using a protected symbol as a variable name.
Change the  (setq acad variable to comething else like (setq *acad*
Don't forget to change all references to this variable.

Not sure if that is your problem though, I don't have 2007.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Lisp compatibility with 2007
« Reply #6 on: October 27, 2006, 08:23:53 AM »
The use of acad as a variable name is acceptable.
The problem IS with the vla-getremotefile function. It is not assigning a valid value to the file variable value. A debug stepthrough halts at (read-line FNO) because FNO is nil because file is "" { an empty string }.

I have no idea why this routine should fail.
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Lisp compatibility with 2007
« Reply #7 on: October 28, 2006, 06:49:00 PM »
Well Thanks for looking at this everyone, I believe it’s some kind of bug or some security feature, the code below returns nil in 2007 when it does not in other versions

Code: [Select]
(defun c:test (/ a acad doc util)
 (setq acad (vlax-get-acad-object)
       doc (vla-get-activedocument acad)
       util (vla-get-utility doc)
 )
 (vla-getremotefile util (strcat "http://ichart.finance.yahoo.com/table.csv?s=DYN&a=10&b=10&c=1993&d=09&e=28&f=2006&g=d&ignore=.csv")
    'file actrue
 )
 file
)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Lisp compatibility with 2007
« Reply #8 on: October 28, 2006, 07:38:28 PM »
Daniel, it actually retutns "" <<- an empty string, not nil.

I thought initially that the actrue should be :vlax-true but both fail.

I have reported this failure on the ADN.
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.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Lisp compatibility with 2007
« Reply #9 on: October 28, 2006, 08:13:22 PM »
If it helps any, I tested this in VBA and obtained the same result. So at least we know it's not in the lisp implementation.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Lisp compatibility with 2007
« Reply #10 on: November 07, 2006, 05:29:52 AM »


Just an update ...




The vla-getremotefile function works correctly in < what will be > AC2008.
It's been fixed as a result of a change request.


Daniel's code from Reply #7 works as expected.

« Last Edit: November 07, 2006, 05:33:47 AM by Kerry Brown »
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Lisp compatibility with 2007
« Reply #11 on: November 07, 2006, 12:22:43 PM »
Oh you’re my hero!
By any chance can you get them to add a grid control to DCL?  :-D

Thanks a Ton!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Lisp compatibility with 2007
« Reply #12 on: November 07, 2006, 03:52:53 PM »
[blush]


wish I had that sort of influence Daniel. !
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8722
  • AKA Daniel
Re: Lisp compatibility with 2007
« Reply #13 on: March 21, 2007, 10:38:58 AM »
I wonder if this does work with 2008?
How many of you bought DYN?

Thanks
Dan