Free Code : Open Files/Folder From Tally (Without DLL Method)

Discussion in 'Free Source Codes' started by Jay kumar tailor, Oct 15, 2019.

    
  1. Jay kumar tailor

    Jay kumar tailor Well-Known Member


    Hi All..
    Jay Here......
    Hope You Will Like......
    Code:
    [#Menu:Gateway OF Tally]
    Add    : Key Item    : Before: @@locQuit    : Files : F : Alter  : SelectjkFiles
    
    
    
    
    [Collection: FilesDir]
    Title:"Select Drive"
    List:"C:\","D:\","E:\","F:\"
    
    [Collection: FilesDir1]
    Title:"Select Folder"
    SubTitle : "File/Folder Name","Size","Read Only","Last Modified Date","Last Modified Time"
    Data Source:Directory:#Dirpath 
    Format :$Name,25
    Format :$Filesize,10
    Format :$IsReadOnly,5
    Format :$LastModifiedDate, 15
    Format :$LastModifiedTime, 15
    
    
    [Collection: Files]
    Title:"Select File"
    SubTitle : "File/Folder Name","Size","Read Only","Last Modified Date","Last Modified Time"
    Data Source:Directory:(#Dirpath+#DirPath1)
    Format :$Name,25
    Format :$Filesize,10
    Format :$IsReadOnly,5
    Format :$LastModifiedDate, 15
    Format :$LastModifiedTime, 15
    
    
    [Report:SelectjkFiles]
        Form :FileSettings
    
    [Form :FileSettings]
           
        Part     :    FileSettings
        On      :      form Accept     : Yes     : Call     : OpenJKTarget
       
    
    [Part :FileSettings]
    
        Line :FileSettings
               
    [Line :FileSettings]
        Field :DirPath,DirPath1,DirPath2
    
    
    [Field :DirPath]
       
        Use : Name Field
        Table:FilesDir
        Dynamic : ""
        Show Table : Always
       
    
    [Field :DirPath1]
       
        Use : Name Field
        Table:FilesDir1,Endoflist
        Dynamic : ""
        Show Table :Always
    
    [Field :DirPath2]
       
        Use : Name Field
        Table : Files,Endoflist
        Dynamic : ""
        Show Table :Always
    
    
       
    [Function:OpenJKTarget]
        001: if :(#Dirpath2 Contains "Endoflist")
        001a : Exec Command    :     (#Dirpath+#Dirpath1)
        002: Else
        002a    : Exec Command        :     (#Dirpath+#Dirpath1+"\"+#DirPath2)
        004: End if
    
       
        
     
    Last edited: Oct 16, 2019


  2. psr

    psr Member


    Thank you.

    Can it be Modified for selecting the data? in Company folder path?
     


  3. Jay kumar tailor

    Jay kumar tailor Well-Known Member


    Yes,
    Already Posted Please Search "Data path"
     
    panam likes this.


  4. psr

    psr Member


    Got It . Thank you so much.
     


  5. Bipin Damania

    Bipin Damania Active Member


    J
    Jayji

    Thanks for Sharing...
    Keep posting...
     
    yacob likes this.


  6. Jay kumar tailor

    Jay kumar tailor Well-Known Member


    Code:
    You May Use Filters As Per Your Requirement.
    
    [#Menu:Gateway OF Tally]
    Add    : Key Item    : Before: @@locQuit    : Files : F : Alter  : SelectjkFiles
    
    
    
    
    [Collection: FilesDir]
    Title:"Select Drive"
    List:"C:\","D:\","E:\","F:\","G:\","H:\","I:\","J:\","K:\","L:\"
    
    [Collection: FilesDir1]
    Title:"Select Folder"
    SubTitle : "File/Folder Name","Last Modified Date","Last Modified Time","File Type"
    Data Source:Directory:#Dirpath
    Format :$Name,25
    Format :$LastModifiedDate, 15
    Format :$LastModifiedTime, 15
    Format : @@JkFileType,10
    
    Filter :JkDir
    ;Filter :OnlyPdf
    ;Filter :OnlyXls
    ;Filter :OnlyXlsx
    ;Filter :OnlyDoc
    
    [Collection: Files]
    Title:"Select File"
    SubTitle : "File/Folder Name","Last Modified Date","Last Modified Time","File Type"
    Data Source:Directory:(#Dirpath+#DirPath1)
    Format :$Name,25
    Format :$LastModifiedDate, 15
    Format :$LastModifiedTime, 15
    Format : @@JkFileType,10
    
    Filter :JkDir
    ;Filter :OnlyPdf
    ;Filter :OnlyXls
    ;Filter :OnlyXlsx
    ;Filter :OnlyDoc
    
    [System : Formulae]
    JkDir    :  ($IsDirectory) OR (($$StringWordEx:$Name:".":@@FileDots:No) Contains "PDF" ) OR (($$StringWordEx:$Name:".":@@FileDots:No) Contains "Doc") OR (($$StringWordEx:$Name:".":@@FileDots:No) Contains "Xls") OR (($$StringWordEx:$Name:".":@@FileDots:No) Contains "Xlsx")
    
    JkFileType : IF ($IsDirectory) Then "Folder" Else @@FileType
    
    
    ;OnlyPdf: ($$StringWordEx:$Name:".":@@FileDots:No) Contains "PDF"
    ;OnlyDoc:($$StringWordEx:$Name:".":@@FileDots:No) Contains "Doc"
    ;OnlyXls:($$StringWordEx:$Name:".":@@FileDots:No) Contains "Xls"
    ;OnlyXlsx:($$StringWordEx:$Name:".":@@FileDots:No) Contains "Xlsx"
    
    [Report:SelectjkFiles]
        Form :FileSettings
    
    [Form :FileSettings]
          
        Part     :    FileSettings
        On      :      form Accept     : Yes     : Call     : OpenJKTarget
      
    
    [Part :FileSettings]
    
        Line :FileSettings
              
    [Line :FileSettings]
        Field :DirPath,DirPath1,DirPath2
    
    
    [Field :DirPath]
      
        Use : Name Field
        Table:FilesDir
        Dynamic : ""
        Show Table : Always
      
    
    [Field :DirPath1]
      
        Use : Name Field
        Table:FilesDir1,Endoflist
        Dynamic : ""
        Show Table :Always
    
    [Field :DirPath2]
      
        Use : Name Field
        Table : Files,Endoflist
        Dynamic : ""
        Show Table :Always
    
    
      
    [Function:OpenJKTarget]
        001: if :(#Dirpath2 Contains "Endoflist")
        001a : Exec Command    :     (#Dirpath+#Dirpath1)
        002: Else
        002a    : Exec Command        :     (#Dirpath+#Dirpath1+"\"+#DirPath2)
        004: End if
    
        
     
    Last edited: Oct 25, 2019
    rmraja and psr like this.


  7. subash pal

    subash pal Member


    Thanks For Sharing
    I am trying File Size in KB, MB, GB but not Succeeded My System formula is given Below Please help for result
    JkFilesize : IF ($Filesize>1023 and $Filesize=1023) Then "B" or ($Filesize=1024 and $Filesize>1048575) Then ($Filesize/1024)+"KB" or ($Filesize=1048576 and $Filesize>1073741823) Then ($Filesize/1048576)+"MB" or ($Filesize=1073741824 and $Filesize<1073741824) Then ($Filesize/1073741824)+"GB" Else $Filesize
     


  8. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    try this (temporary) ---- JkFilesize : $Filesize or use some "dummy text"

    If not working after above, then problem is elsewhere.

    Also re-check your last condition for GB in the above formula.
     
    subash pal likes this.


  9. subash pal

    subash pal Member



    Thanks for Reply

    only $filesize Accepted and its result in byte, Any other text after $Filesise Not Accepted, Like $FileSize, "KB" , $Filesize+"KB"
     


  10. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    give proper code to identify mistake.....is your FIELD -- numeric???
     


  11. subash pal

    subash pal Member


    I am Using in Collection in above "open File module" as Below

    [Collection: Files]
    Title:"Select File"
    SubTitle : "File/Folder Name","File Type","File Size","Last Modified Date","Last Modified Time"
    Data Source:Directory:(#Dirpath+#DirPath1)
    Format :$Name,25
    Format : @@JkFileType,10
    Format : @@JkFilesize,10
    Format :$LastModifiedDate, 15
    Format :$LastModifiedTime, 15

    [System : Formulae]
    JkFileType : IF ($IsDirectory) Then "Folder" Else @@FileType
    JkFilesize : IF ($Filesize>1023 and $Filesize=1023) Then "B" or ($Filesize=1024 and $Filesize>1048575) Then ($Filesize/1024)+"KB" or ($Filesize=1048576 and $Filesize>1073741823) Then ($Filesize/1048576)+"MB" or ($Filesize=1073741824 and $Filesize<1073741824) Then ($Filesize/1073741824)+"GB" Else $Filesize
     


  12. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    use $$String before all the quotes.
     


  13. subash pal

    subash pal Member


    Not Worked

    Message "Bad Formula"
     


  14. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    If you want good guidance, then kindly share the code snippet, so others can verify and check it out. Just mere comments is not enough.

    Show ---- what you have done and typed.......and show full details.
     


  15. subash pal

    subash pal Member


    Thank You sir

    Here is Full Code


    [#Menu:Gateway OF Tally]
    Add : Key Item : Before: @@locQuit : Files : F : Alter : SelectjkFiles ;TSPL Smp Directory Data Source;
    Add : Key Item : Before: @@locQuit : Blank



    [Collection: FilesDir]
    Title:"Select Drive"
    List:"C:\","D:\","E:\","F:\"
    [Collection: FilesDir1]
    Title:"Select Folder"
    SubTitle : "File/Folder Name","File Type","File Size","Last Modified Date","Last Modified Time"
    Data Source:Directory:#Dirpath
    Format :$Name,25
    Format : @@JkFileType,10
    Format : @@JkFilesize,10
    Format :$LastModifiedDate, 15
    Format :$LastModifiedTime, 15



    [Collection: Files]
    Title:"Select File"
    SubTitle : "File/Folder Name","File Type","File Size","Last Modified Date","Last Modified Time"
    Data Source:Directory:(#Dirpath+#DirPath1)
    Format :$Name,25
    Format : @@JkFileType,10
    Format : @@JkFilesize,10
    Format :$LastModifiedDate, 15
    Format :$LastModifiedTime, 15



    [System : Formulae]

    JkFileType : IF ($IsDirectory) Then "Folder" Else @@FileType
    ;;$Filesize
    JkFilesize : IF ($Filesize>1023 and $Filesize=1023) Then "B" or ($Filesize=1024 and $Filesize>1048575) Then ($Filesize/1024)+"KB" or ($Filesize=1048576 and $Filesize>1073741823) Then ($Filesize/1048576)+"MB" or ($Filesize=1073741824 and $Filesize<1073741824) Then ($Filesize/1073741824)+"GB" Else $Filesize

    [Report:SelectjkFiles]
    Form :FileSettings

    [Form :FileSettings]

    Part : FileSettings
    On : form Accept : Yes : Call : OpenJKTarget

    [Part :FileSettings]

    Line :FileSettings

    [Line :FileSettings]
    Field :DirPath,DirPath1,DirPath2


    [Field :DirPath]
    Use : Name Field
    Table:FilesDir
    Dynamic : ""
    Show Table : Always

    [Field :DirPath1]
    Use : Name Field
    Table:FilesDir1,Endoflist
    Dynamic : ""
    Show Table :Always

    [Field :DirPath2]
    Use : Name Field
    Table : Files,Endoflist
    Dynamic : ""
    Show Table :Always


    [Function:OpenJKTarget]
    001: if :(#Dirpath2 Contains "Endoflist")
    001a : Exec Command : (#Dirpath+#Dirpath1)
    002: Else
    002a : Exec Command : (#Dirpath+#Dirpath1+"\"+#DirPath2)
    004: End if
    /* =================Data Storage=======================


    Data Storage Units
    Bit 1 or 0
    Byte (B) 8 Bits
    Kilobyte (KB) 1024 Bytes
    Megabyte (MB) 1024 Kilobytes
    Gigabyte (GB) 1024 Megabytes
    Terabyte (TB) 1024 Gigabytes
    Petabyte (PB) 1024 Terabytes
    Exabyte (EB) 1024 Petabytes
    Zettabyte (ZB) 1024 Exabytes
    Yottabyte (YB) 1024 Zettabytes
    Brontobyte (XB) 1024 Yottabyte

    */============================end
     


  16. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    You must learn to construct the formula properly. There are many examples in TDE. Also when learning or new, always break down the formula in parts, so it is easier to learn, develop and implement/change readily.

    Code:
    JkFilesize : IF ($Filesize>0 and $Filesize<=1023) Then $$String:@@FileinByteR + $$String:"B" Else +
                If ($Filesize>=1024 and $Filesize<=1048575) Then $$String:@@FileinKBR + $$String:"KB" Else +
                If ($Filesize>=1048576 and $Filesize<=1073741823) Then $$String:@@FileinMBR + $$String:"MB" Else +
                If $Filesize>=1073741824 Then $$String:@@FileinGBR + $$String:"GB" Else ""
    
    FileinByte    : $Filesize
    FileinKB    : $Filesize/1024
    FileinMB    : $Filesize/1048576
    FileinGB    : $Filesize/1073741824
    
    FileinByteR    : $$Round:@@FileinByte:0
    FileinKBR    : $$Round:@@FileinKB:0
    FileinMBR    : $$Round:@@FileinMB:0
    FileinGBR    : $$Round:@@FileinGB:0
    
     


  17. subash pal

    subash pal Member


    Thank You sir For Guidance & Support, Its worked
     


  18. Jay kumar tailor

    Jay kumar tailor Well-Known Member


    Thanks Sir
    For Making Good Correction's.
     


  19. NIRMALGHORAWATIN

    NIRMALGHORAWATIN New Member


    Hello @JayKumarTailor @AmitKamdar & Friends

    I have used File Selection Template and that gives Browse Directory Feature. Sharing the sample code. How can I also get Directory Path, please guide.

    Code:
    /*
    This section Contains the TDL Code for File Selection Template
    */
    
    [#Menu:Gateway OF Tally]
    Add    : Key Item    : Before: @@locQuit    : Files : F : Alter  : SelectFileModule
    
    [Report: SelectFileModule]
        Form :FileSettingsModule
    
    [Form :FileSettingsModule]
        Part     :    FileSettingsModule
        On      :      form Accept     : Yes     : Call     : DispImpFile
    
    [Part: FileSettingsModule]
    Add : Lines : ImportFile2   
    
    [Line: ImportFile2]
    Fields : Medium Prompt, ImportFileName
    Local : Field : Medium Prompt : Setas : "Select File to Import:"
    Local : Field : Medium Prompt : Color : Blue
    
    [Field: ImportFileName]
    Use                  : File Selection Template
    Modifies             : ImportFileName : Yes  : $$TableObj:ImportFileName:$Path
    Case                 : Normal 
    Width                : @@LongWidth+10
    Max                  : @@MaxNarrWidth
    Act on Table Element : (@ShowMore OR @ShowLess) : Execute Obj Actions : ShowMoreLess
    ShowMore             : ($$IsSysNameEqual:ShowMore:($$CurrentTableObj:$Name))
    ShowLess             : ($$IsSysNameEqual:ShowLess:($$CurrentTableObj:$Name))
    
    [System: UDF]
        ImportFileName: String: 9001
      
    [Function: DispImpFile]
        010: Msg Box: "Import File Path": ""
        015: Msg Box: "Import File Name": #ImportFileName
        020: Return
    
     
    Last edited: Oct 14, 2023


  20. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Use -- Folder selection Template in your Folder Field to select Folders.
     
    NIRMALGHORAWATIN likes this.


  21. Amrik

    Amrik New Member



Share This Page