#50128 - 2000-06-20 06:30 PM
Re: Handling dates
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Gang:Ok – here’s my un-orthodox approach to handling dates and floating-point math in KiX The following script instantiates an instance of Excel, prompts for a formula, plugs it into Excel, then displays the calculated value. Note: the KiX OleReleaseObject() function doesn't seem to want to release out-of-proc servers (excel.exe). I think word.exe has the same problem. Not sure if this is a KiX OLE thing or an Office OLE thing but can anybody fix ? Here's some relevant things to try: Formula: 1+1 Formula: .001 + .00234 (for you math hounds) Formula: text(datevalue("20-JUN-2000")-14,"dd-mmm-yyyy") (jochen hmmm ?) Formula: datevalue("20-JUN-2000")-datevalue("03-JUL-1969") (days between) If anyone has trouble cutting and pasting, please advise. Anyway - here goes: code:
break on cls ;------------------------------------------------ ; OLE Formula 1 Driver (hehe) ; ; Enter "quit" to quit ;------------------------------------------------
; Create an instance of Excel (excel.exe)
$excel = olecreateobject ( "excel.application" )
if $excel = 0
?"Excel (ole) is not supported on this machine"
exit
endif
; Comment/Uncomment next line for the visuals ; Remember to re-focus back to your DOSBOX if you do
; $rs = oleputproperty ( $excel, "visible", "b", "1" )
; Disable alerts (i.e. don't ask if I want to save my work)
$rs = oleputproperty ( $excel, "displayalerts", "b", "0" )
; Get a handle to the workbooks object
$workbooks = val("&"+olegetproperty ( $excel, "workbooks" ))
; Open a new workbook & sheet
$rs = olecallfunc ( $workbooks, "add" )
; Get a handle to the default active cell (A1)
$cell = val("&"+olegetproperty ( $excel, "activecell" ))
while 1
? ?"Formula : " gets $formula
if $formula = "quit" goto finish endif
$rs = oleputproperty ( $cell, "formula", "s", "=$formula" )
?"Answer : " olegetproperty ( $cell, "value" )
loop
:finish
$rs = olecallfunc ( $excel, "exit" )
$rs = olereleaseobject ( $excel )
? ?"Use taskmgr.exe to manually terminate excel.exe" ?
exit
Shawn.
[This message has been edited by Shawn (edited 20 June 2000).]
|
Top
|
|
|
|
#50132 - 2000-06-20 09:10 PM
Re: Handling dates
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
We're knights of the round table, we dance whene're we're able. We do routines, and border scenes, and footwork imp-e-cable; We dine well here in Camelot, we eat ham and jam and spamalot. We're knights of the round table, our shows are for-mid-able The many times, we're given rhymes, that are quite un-sing-able We're often mad in Camelot, we sing from the lie of hamalot! Though we're tough and able, Quite in-de-fa-ti-gable, Between our quests, we seek incest and impersonate Clark Gable, It's a busy life in Camelot: (Bass-Solo): I have to push the pram-a-lot! Arthur: On second thought, let's not go to Camelot. It is a silly place. Assorted Knights: (mumble) Yeah, let's go, agreed, etc...
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 366 anonymous users online.
|
|
|