How to Call .Net Dll From TDL

Discussion in 'Tally Developer' started by Azar Shaikh, Sep 1, 2012.

    
  1. Azar Shaikh

    Azar Shaikh New Member


    ;; Following Code Open windows File Browser and Return File Name To TDL you Selected.

    [#Menu : Gateway of Tally]
    Item : Dll File Browse : Call : Dll File Browse

    [Function : Dll File Browse]
    Variable : vFileName : String
    10 : Walk Collection : Dll Collection
    20 : Set : vFileName : $Name
    30 : End Walk
    40 : MsgBox : "File Name" : ##vFileName

    [Collection : Dll Collection]

    Data Source : AxPlugin XML : FilBrowseDll.Class1
    XML Object Path : Object : 1 :Collection

    ;; Note : Dll Must be Register to windows
    ;;Dll need to Return Xml String
    ;; Dll Function Name Must Be " TDLCollection"
     


  2. admin

    admin Administrator Staff Member


    What is This? Do u need any help? or Is this working code, you need to share to all TDLeXperts members?

    Could not get it sir.
     
    vinay likes this.


  3. Azar Shaikh

    Azar Shaikh New Member


    Sorry Sir I Couldn't Verify Title Before Post Upload .And Unable to Change Title after Upload. But Its Working Code to Call .Net Dll From Tally. $$CallDllFunction Allow Only C++ Dll So to Call .Net Dll above Code is Required. Thanks
     


  4. Dhanapal Amulraj

    Dhanapal Amulraj New Member


    Hello Azar Shaikh,

    i have tried your above Dotnet DLL calling Code, but that is not working for my DLL.
    Here by i have attached my Dotnet DLL in .TXT Format, after get downloaded please change it into .DLL Format.
    and i have wrote the function below, which i used in the attached DLL,
    i couldn't able to move further with your code, could you please give me the solution for it.

    Note :
    DLL Name : TallyDLL
    Class Name : ClsTallyDLL
    Method Name : TDLCollection




    Technology : C#.Net , 3.5 Framework.


    Function which i used in the DLL: (FYR)


    public class ClsTallyDLL
    {
    public string TDLCollection()
    {
    string filepath = "C:\\create.txt";
    if (File.Exists(filepath))
    {
    File.Delete(filepath);
    }
    FileStream fs = File.Open(filepath, FileMode.CreateNew, FileAccess.Write);
    fs.Close();
    string xml = "<Collection>";
    xml += "<Ledger>";
    xml += "<LedgerName>Purchases @ 5%</LedgerName>";
    xml += "<LedgerParent>Purchase Accounts</LedgerParent>";
    xml += "</Ledger>";
    xml += "</Collection>";
    return xml;
    }
    }

    Thanks and Regards,
    Dhanapal Amulraj.
     

    Attached Files:

    JObimon Arackal JOhn likes this.



  5. Dear Mr.Azar,

    Can you share the dll file.

    Thanks & Regards,
    A.Marudhachalamurthi
     



  6. Dear Azar

    share the dll file.
     


  7. Azar Shaikh

    Azar Shaikh New Member


    Imports System.Windows.Forms.OpenFileDialog

    Public Class Class1
    Public Function TDLCollection(ByVal pInputparam As String, ByVal pInputXML As String)
    Dim Str As String
    Dim fd As New System.Windows.Forms.OpenFileDialog
    Dim dr As New System.Windows.Forms.DialogResult
    Dim filename As String
    fd.ShowDialog()
    filename = fd.FileName

    Str = "<Collection>" + vbCrLf
    Str = Str + " <Object>" + vbCrLf
    Str = Str + "<Name>" + filename + "</Name>" + vbCrLf
    Str = Str + "</Object>" + vbCrLf
    Str = Str + "</Collection>" + vbCrLf

    Return Str
    End Function
    End Class
    ;; Note : Need to Register your dll
     


  8. Dhanapal Amulraj

    Dhanapal Amulraj New Member


    Hi Azar,
    i have 2 questions.
    one is How to register Dotnet Dll in windows
    and
    second one is i couldn't able to reach the result of your code, can you please share the DLL and TDL files to my personal mail id. dbalacs04archive@gmail.com, please do the needful,
    please let me know once you sent mail.

    Thanks in advance

    Regards,
    Dhanapal Amulraj.
     


  9. Dhanapal Amulraj

    Dhanapal Amulraj New Member


    Hi Azar,
    i have 2 questions.
    one is How to register Dotnet Dll in windows
    and
    second one is i couldn't able to reach the result of your code, can you please share the DLL and TDL files to my personal mail id. dbalacs04archive@gmail.com, please do the needful,
    please let me know once you sent mail.

    Thanks in advance

    Regards,
    Dhanapal Amulraj.
     


  10. Rizvi

    Rizvi New Member


    Mr. Azhar Can u provide the Dll and the complete process to get windows explorer and file name to tdl.
     


  11. Suresh

    Suresh New Member


    Hi, any one is looking for this type of tdl & dll file ?
     

    Attached Files:



  12. Rizvi

    Rizvi New Member


    Thanks Mr. Suresh, but the dll file is not being registered and it does not work, can u let me know the process of attaching the docs.
     


  13. Rizvi

    Rizvi New Member


    It is opening but how can we use for our customization..
     


  14. Suresh

    Suresh New Member


    Hi, we can used the dll in Default Tally & in tdl also
    in default Tally, it is useful to fields "Company path of Data, Export location, logo image path, etc..."
    which we type manually the path of file or folder name
    in tdl, suppose for school, student is a ledger, so we can add the dll function to add the image of that student, we can select the image, no need to type manually
    got it ?
     


  15. Dhanapal Amulraj

    Dhanapal Amulraj New Member


    Hi Suresh,i can get your point. Can you please share the simple code of Dotnet DLL and the TDL Code.,
    i am looking for this by last 3 months, still i am unable to reach it. Plesae do the needful
    Thanks in advance,

    Regards,
    Dhanapal Amulraj
     


  16. Rizvi

    Rizvi New Member


    Thanks for your reply.. Can u pls share the sample code as I am new to the tdl and integration.
     


  17. Suresh

    Suresh New Member


    check this sample tdl used in default tally


    [#Menu : Gateway of Tally]
    key Item : "Document Select" : L: alter : Ta LDoc Files

    [Report : Ta LDoc Files]
    Form : Ta LDoc Files
    Title : "Documents to Attach"

    [Form : Ta LDoc Files]
    Part : Ta LDoc Files
    Space Top : 0.5
    Space Left : 1
    Space Right : 1
    Background : @@SV_LOGIN
    Full Width : No
    Full Height : No
    Vertical Align : Centre

    [Part : Ta LDoc Files]
    Option : Small Size Part
    Line : Form SubTitle
    Line : Ta Image File, Ta XML File, Ta Folder Name
    Local : field : form subtitle : set as :"Sample"
    Vertical : Yes
    Space Bottom: 0.5


    [Line : Ta Image File]
    Field : Medium Prompt, Ta Image File, Ta Image FileB
    local : Field : Medium Prompt : Info : "Image File path :"
    Space Bottom: 0.5

    [Field : Ta Image File]
    Use : Name Field
    ;Modifies : ImageFilePath
    Set as : ##ImageFilePath
    Set Always : Yes
    Skip : Yes
    ;On : Focus : Yes : Call : SetTFIValueImage
    [Field : Ta Image FileB]
    Use : Short Name Field
    Set as : "Browse"
    Align : Center
    Width : 9
    Key : ImageKey
    Border : Thin Box
    Read Only : Yes
    Tooltip : "Click to browse image file"

    [Key : ImageKey]
    Key : Left Click
    Action : Call : SetTFIValueImage

    [Function : SetTFIValueImage]
    VARIABLE : ImagePath : String
    Variable : ImageFileVar : String
    01 : If : $$IsFieldEdited
    02 : SET : ImageFilePath : "" ;$$Value
    03 : Else
    04 : SET : ImageFilePath : $(AppINIConfig, "AppINIConfig").ExportPath
    05 : END IF
    06 : Set : ImageFilePath : $$CallDllFunction:TFI:OpenFileDialogForImage:##ImageFilePath:"A":"B":"C"
    07 : IF : Not ImagePath = ""
    08 : SET : ImageFileVar : ##ImagePath
    09 : END IF

    ;;; in the above function "TFI" is the dll name & "OpenFileDialogForImage" is function name in that dll

    ;;other function in that dll are "OpenFileDialogForXML", "OpenFolderDialog"

    i think u can understand
     


  18. Dhanapal Amulraj

    Dhanapal Amulraj New Member


    Yes Suresh, The Code is Very Clear, Please share the "Dotnet DLL class and Method Coding" , because i used the same "$$CallDllFunction" its not working for me earlier,
    Please share the Dotnet Code., which helps me a lot.

    Thanks in Advance,
    Regards,
    Dhanapal Amulraj
     


  19. Suresh

    Suresh New Member


    Sorry, i will not share the dll code, but i told u the function names, so that you can use the functions in your projects
    i have not added any limitations in that dll
    Thanking you
     


  20. Dhanapal Amulraj

    Dhanapal Amulraj New Member


    Did u used Dotnet DLL???
     


  21. Suresh

    Suresh New Member


    Yes, it is .net dll, if you need any help, post it here
     


  22. Dhanapal Amulraj

    Dhanapal Amulraj New Member


    Dear Suresh,
    Here by i have attached my Dotnet code and TDL code, please check it and debug it.
    I have tried a lot, its not working, please help me, and please let me know what wrong i did..

    Please Find Attachment.


    Thanks in Advance,
    Regards,
    Dhanapal Amulraj
     

    Attached Files:



  23. Suresh

    Suresh New Member


    Hi, the function in dll is not like that, if u want to push values from tdl, it must be like below
    explanation:
    v1, v2, v3 are the values u are pushing from tdl to dll function, ofcourse u can input as manu u can
    v4 is the total of that inputs (if numbers)
    so it will return the result by swprintf command


    int DllAddFunction( short, wchar_t * Data[], wchar_t **Output, SIZE_T *OutputSize )
    {
    int i;
    int j;
    int v21;
    int result = 1;

    if ( Data[0] )
    {
    *OutputSize = 50;
    *Output = (wchar_t *) CoTaskMemAlloc(*OutputSize);

    if ( *Output )
    {
    wchar_t *EndPtr;

    double v1 = wcstod(Data[0], &EndPtr); // input 1 from tally tdl
    double v2 = wcstod(Data[1], &EndPtr); // input 2 from tally tdl
    double v3 = wcstod(Data[2], &EndPtr); // input 3 from tally tdl

    double v4 = (v1 + v2 + v3) * 2;

    swprintf(*Output, L"%.10lf", v4);

    }
    }

    return result;
    }
     


  24. Dhanapal Amulraj

    Dhanapal Amulraj New Member


    Suresh,, i pasted this code in dotnet but it shows error. can u please alter it in my project and resend it to me,
    pls
     


  25. Suresh

    Suresh New Member


    Hi, my code is c++ not c#
     


Share This Page