Page 2 of 18

Posted: Fri Apr 20, 2007 2:52 pm
by Beach
Very nice, thank you!

Posted: Fri Apr 20, 2007 3:37 pm
by Thalius
Hell! Thx TS !

Yet another brilliant Lib!

Thalius

Posted: Fri Apr 20, 2007 3:49 pm
by netmaestro
Most excellent contribution, should be taken native! Thanks so much for this.

Posted: Fri Apr 20, 2007 3:50 pm
by Pantcho!!
netmaestro wrote:Most excellent contribution, should be taken native! Thanks so much for this.
can we vote?

ahh I vote YES.

Posted: Fri Apr 20, 2007 4:00 pm
by ts-soft
Good news: a unicode Version is in progress :wink: ,
but i think not 100% Syntaxcompatible.

The PB-TEAM has in the moment, no time for this, but we can hope a bit.

Posted: Fri Apr 20, 2007 5:49 pm
by Q*bert
WOW!!! :shock: This is fantastic!!!

This lib opens up (or at least makes easily accessible) a whole new world for PB developers.

Thanks so much!

Posted: Fri Apr 20, 2007 6:24 pm
by ts-soft
New example by Kiffi

Code: Select all

; example by Kiffi

EnableExplicit

Define.l ExcelApp, Workbook

dhToggleExceptions(#True)

ExcelApp = dhCreateObject("Excel.Application")

If ExcelApp
  
  dhPutValue(ExcelApp, ".Visible = %b", #True)
  
  dhGetValue("%o", @Workbook, ExcelApp, ".Workbooks.Add")
  
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 1, @"Feel")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 2, 1, @"the")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 3, 1, @"pure")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 4, 1, @"Power")
  
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 2, @"the")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 3, @"pure")
  dhPutValue(ExcelApp, "Cells(%d, %d).Value = %s", 1, 4, @"Power")

  MessageRequester("PureDispHelper-ExcelDemo", "Click OK to close Excel")
  
  dhCallMethod(ExcelApp, ".Quit")
  
  dhReleaseObject(Workbook) : Workbook = 0
  dhReleaseObject(ExcelApp) : ExcelApp = 0
  
Else
  
  MessageRequester("PureDispHelper-ExcelDemo", "Couldn't create Excel-Object")
  
EndIf

Posted: Fri Apr 20, 2007 7:15 pm
by srod
This is great, please keep those examples coming! :)

For COM duffers like myself, I need all the examples I can get hold of!

Thanks.

Posted: Fri Apr 20, 2007 7:19 pm
by akj
This COM library is so important to the future of PureBasic and is likely to generate so many examples that I think a new Forum section called 'COM Objects' should be created.

Posted: Fri Apr 20, 2007 9:23 pm
by Num3
This community ROCKS!!!

Purebasic is the language!

Posted: Fri Apr 20, 2007 9:28 pm
by ts-soft
srod wrote:This is great, please keep those examples coming! :)
Okay, for srod another agent example with Merlin :wink:

Code: Select all

; example by ts-soft

EnableExplicit

dhToggleExceptions(#True)

Define.l oAgent, oMerlin
Define.s item

oAgent = dhCreateObject("Agent.Control.2")

If oAgent = 0
[img]http://ts-soft.eu/dl/puredisphelper.png[/img]  Debug "error: can't create object"
  End
EndIf

dhPutValue(oAgent, "Connected = %b", #True)
dhCallMethod(oAgent, "Characters.Load(%s,%s)", @"Merlin", @"Merlin.acs")
dhGetValue("%o", @oMerlin, oAgent, "Characters(%s)", @"Merlin")

If oMerlin = 0
  Debug "error: can't create object"
  End
EndIf

dhCallMethod(oMerlin, "Show")

If OpenWindow(0, 0, 0, 200, 200, "Merlin - Demo", #PB_Window_ScreenCentered|#PB_Window_SystemMenu) And CreateGadgetList(WindowID(0))
  
  ListViewGadget(0, 5, 5, 190, 165)
  ButtonGadget(1, 70, 177, 60, 20, "Play")
  
  Restore Merlin
  
  Repeat
    Read item
    If item <> ""
      AddGadgetItem(0, #PB_Any, item)
    EndIf
  Until item = ""
  
  dhCallMethod(oMerlin, "MoveTo(%d,%d)", WindowX(0) + 40, WindowY(0) - 120)
  dhCallMethod(oMerlin, "Play(%s)", @"GetAttention")
  dhCallMethod(oMerlin, "Play(%s)", @"GetAttentionContinued")
  dhCallMethod(oMerlin, "Speak(%s)", @"Can I do something for you?")
  dhCallMethod(oMerlin, "Play(%s)", @"GetAttentionReturn")
  SetGadgetState(0, 0)
   
  Repeat
  
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        CloseWindow(0)
        dhCallMethod(oMerlin, "Stop")
        dhCallMethod(oMerlin, "Play(%s)", @"Hide")
        Delay(3000)
        Break
    
      Case #PB_Event_MoveWindow
        dhCallMethod(oMerlin, "MoveTo(%d,%d)", WindowX(0) + 40, WindowY(0) - 120)
          
      Case #PB_Event_Gadget
      
        Select EventGadget()
          Case 1
            item = GetGadgetText(0)
            If Item = "Speak"
              Item = InputRequester("Merlin", "What should i say?", "")
              If Item <> ""
                dhCallMethod(oMerlin, "Speak(%s)", @Item)
              EndIf
            Else
              dhCallMethod(oMerlin, "Stop")
              dhCallMethod(oMerlin, "Play(%s)", @item)
            EndIf
        EndSelect
    EndSelect
    
  ForEver
EndIf

dhReleaseObject(oMerlin) 
dhReleaseObject(oAgent)

DataSection
  Merlin:
  Data.s "Acknowledge", "Alert", "Announce", "Blink", "Confused", "Congratulate"
  Data.s "Congratulate_2", "Decline", "DoMagic1", "DoMagic2", "DontRecognize"
  Data.s "Explain", "GestureDown", "GestureLeft", "GestureRight", "GestureUp"
  Data.s "GetAttention", "GetAttentionContinued", "GetAttentionReturn", "Greet"
  Data.s "Hearing_1", "Hearing_2", "Hearing_3", "Hearing_4", "Hide", "Idle1_1"
  Data.s "Idle1_2", "Idle1_3", "Idle1_4", "Idle2_1", "Idle2_2", "Idle3_1", "Idle3_2"
  Data.s "LookDown", "LookDownBlink", "LookDownReturn", "LookLeft", "LookLeftBlink"
  Data.s "LookLeftReturn", "LookRight", "LookRightBlink", "LookRightReturn"
  Data.s "LookUp", "LookUpBlink", "LookUpReturn", "MoveDown", "MoveLeft", "MoveRight"
  Data.s "MoveUp", "Pleased", "Process", "Processing", "Read", "ReadContinued"
  Data.s "Reading", "ReadReturn", "Sad", "Search", "Searching", "Show", "Speak"
  Data.s "StartListening", "StopListening", "Suggest", "Surprised", "Think", "Thinking"
  Data.s "Uncertain", "Wave", "Write", "WriteContinued", "WriteReturn", "Writing"
  Data.s ""
EndDataSection
Image

Have fun

Posted: Sat Apr 21, 2007 9:00 am
by Dare
srod wrote:This is great, please keep those examples coming! :)

For COM duffers like myself, I need all the examples I can get hold of!

Thanks.
* Takes a seat in the duffers section *

Hear Hear!


This is really good. The problem now is the candy (flash, movies, etc) are distracting me from the meat (ADO, etc).

Posted: Sat Apr 21, 2007 10:15 am
by srod
:D

(Pokes head out from around duffers corner to ask ts-soft a ridiculously dumb question!)

ts-soft: when creating an object; e.g. in your example above, how do know the name of the object? E.g. you used 'Agent.Control.2' in the above example. Where do you find details on these names?

Thanks.

Posted: Sat Apr 21, 2007 10:41 am
by ts-soft
>> Where do you find details on these names?
PSDK, Ole-COM ObjectViewer, Help for VBScript/VB, Google, VB-Foren and Biily :wink:

Many c-examples in the source-package of disphelper!

Posted: Sat Apr 21, 2007 10:53 am
by srod
Right, I think a crash course in VBScript is called for. :)

Thanks.

Reiterating someone else's suggestion; a COM section to these forums would be great, especially now that you've opened up the world of COM to duffers like myself and dare with this brilliant piece of work.

Right, who runs these forums? Fred lad where are you? :)