News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MasmBasic

Started by jj2007, May 23, 2012, 10:16:07 PM

Previous topic - Next topic

Gunther

Jochen,

looks like a rock solid work.  :t

Gunther
You have to know the facts before you can distort them.

jj2007

Danke, Gunther :icon14:

Although DDE is an old technology, there are some arguments for using it - it's fast, lightweight, and there is no "version hell" as (reportedly) with the alternative COM technology. What I really needed was pulling tables programmatically out of an Excel file - sounds simple but if you don't want the user to install add-ins (with all the nice warnings about untrusted software etc), then DDE is probably the only option.

One problem is the documentation; DDE uses the old Excel 4.0 macro language, the only official source is "MacroFun.hlp" from Microsoft Support.

TouEnMasm

Quote
What I really needed was pulling tables programmatically out of an Excel file

If it is just for that,ODBC is better (same language since ....)
Fa is a musical note to play with CL

japheth

Quote from: ToutEnMasm on April 05, 2013, 12:11:21 AM
If it is just for that,ODBC is better (same language since ....)

What is better with ODBC?

- DDE  = dinosaur technology
- COM/OLE = pleistocene
- ODBC = ??? (  perhaps eocene? )

TouEnMasm

Quote
What is better with ODBC?
The Use of sql with it , simplify the work.
Simple to use,you don't need to know all the langage.
Access can generate SQL for you.

http://msdn.microsoft.com/en-us/library/bb545450.aspx
2012 isn't so old.



Fa is a musical note to play with CL

dedndave

i mentioned in the other thread that i had to have Excel for a business client
what i did at the time was - Save Special (without the cell formulas) - Save As CSV
then, i wrote a csv2bin program in 16-bit code   :P

jj2007

Quote from: ToutEnMasm on April 05, 2013, 12:11:21 AM
Quote
What I really needed was pulling tables programmatically out of an Excel file

If it is just for that,ODBC is better (same language since ....)

Hi Yves,

Please show me. Write a little example  - just extracting a table by RnCn:RmCm coordinates.
The testfile is at \Masm32\RichMasm\Res\LifeExOECD.xls

:t

TouEnMasm


The file is not a database.
A database had columns titles on the first line.
Do it and no more problems.
Fa is a musical note to play with CL

jj2007

Quote from: ToutEnMasm on April 05, 2013, 12:11:21 AM
If it is just for that,ODBC is better (same language since ....)

There is an old German proverb: Wer gackert muss auch legen. Free translation "He who cackles must lay an egg".

Waiting for your sample code showing that "ODBC is better", Yves :biggrin:

(the requirement is very simple, "get data out of Excel without the user having to install an add-in or a macro; establish a hotlink so that Excel sends data to your proggie every time the Excel user has changed a cell". It would also nice to preserve the formatting as shown in the attached example - source in \Masm32\RichMasm\Res\XlsViewer.asc. If you change the ending to .edm, you can even view it in EditMasm, as it's RTF...)

TouEnMasm


Quote
What I really needed was pulling tables programmatically out of an Excel file
For That,not for all thing you want to do.

Fa is a musical note to play with CL

jj2007


japheth

Quote from: jj2007 on April 05, 2013, 05:53:12 AM
Quote from: ToutEnMasm on April 05, 2013, 12:11:21 AM
Waiting for your sample code showing that "ODBC is better", Yves

I cannot see why he needs to provide "sample code" - that's an additional requirement imposed by you, troll!  :icon_mrgreen:

Actually, it is sufficient if a plausible reason is supplied that makes obvious - more or less -  that ODBC is at least in one aspect better than DDE.

One possible reason that comes into my mind is that DDE requires a window for communication, while ODBC does NOT requires this.

jj2007

#57
Quote from: japheth on April 05, 2013, 06:48:44 AMOne possible reason that comes into my mind is that DDE requires a window for communication, while ODBC does NOT requires this.

Thanks for this clarification, Andreas. I wonder, though, why the attached executable works - must be an invisible window then  ::)

Source is in \Masm32\RichMasm\Res\Masm2Excel.asc, the Excel sheet at \Masm32\RichMasm\Res\LifeExOECD.xls ;-)

Still waiting for demo code (or at least: arguments) why ODBC is better than DDE for grabbing data from an Excel sheet ;-)

EDIT: To complete the DDE interface, I added four new macros, ddeConnect, ddeDisconnect, ddeCommand and ddeRequest$(). This snippet shows the Firefox URL currently loaded, and if the user presses y, it opens a new page (code for MSIE attached):

include \masm32\MasmBasic\MasmBasic.inc        ; download
  Init
  ddeConnect "Firefox|WWW_GetWindowInfo"
  .if !Zero?
        PrintLine "Current URL= ", ddeRequest$("URL")
        ddeDisconnect
        Inkey "Open a new page (y)?"
        .if eax=="y"
                ddeConnect "Firefox|WWW_OpenURL"
                .if !Zero?
                        ddeCommand "http://masm32.com/board/index.php?action=unread"
                        ddeDisconnect
                .endif
        .endif
  .endif
  Inkey CrLf$, "bye"
  Exit
end start

jj2007

Bugfix concerning \Masm32\RichMasm\Res\Masm2Excel.asc, line 51:

Wrong:
                mov ecx, Instr_(esi, "[Book")                ; this might fail for a non-English Excel version
                .if ecx
                        .if Instr_(ecx, esi, Tb$)
                                xlsConnect Mid$(esi, ecx, edx-1)          ; connect to the new sheet
                        Let TopBot$=String$(9, Cat$("xxxxxxxxx"+Tb$))+"x"
                        xlsWrite "R2C3:R2C14", TopBot$

Right:
                mov ecx, Instr_(esi, "[Book")                ; this might fail for a non-English Excel version
                .if ecx
                        .if Instr_(ecx, esi, Tb$)
                                xlsConnect Mid$(esi, ecx, edx-ecx)          ; connect to the new sheet
                        Let TopBot$=String$(9, Cat$("xxxxxxxxx"+Tb$))+"x"
                        xlsWrite "R2C3:R2C14", TopBot$

Excel 2003 did not complain about being connected to [Book1]Sheet1 whatever, but Excel 2010 didn't like it  :biggrin:

Updated library here, as always.

japheth

Quote from: jj2007 on April 05, 2013, 07:31:39 AM
Thanks for this clarification, Andreas. I wonder, though, why the attached executable works - must be an invisible window then  ::)

Yes, I guess that's true. Sorry, can't really run your sample because I threw away the MSO BS from this machine - and the one where it's still installed is now too noisy for my taste.