Tally Auto Backup

Discussion in 'Free Source Codes' started by abhinand vk, Jun 5, 2020.

    
  1. abhinand vk

    abhinand vk Active Member


    How to enable auto backup query box on tally Application closing please help​




    [#Menu: Gateway of Tally ] ;; Adding a Menu Item to Configure My Backup - F12 -> My Backup

    Add : Key Item : After : @@locquit : "My Backup" : K : Execute : TSPL FFE UCB Config

    Control : "My Backup" : NOT $$IsRemoteCompany AND ##SVQuitFromRemoteLogout != 1

    [Report: TSPL FFE UCB Config]

    Title : $$LocaleString:"Configure Backup"
    Object : BackCmpList

    [Form: TSPL FFE UCB Config]

    Use : System Configuration
    width : 40% Screen
    height: 30% Screen
    Delete : Parts
    Add : Parts : Form SubTitle, TSPL FFE Enable UCB
    Local: Field: Form SubTitle : Info : "Configure Backup"
    Bottom Part:smsMark

    ;; On saving the Form, calling a function to update the selected companies to the persistent List Variables
    On : Form Accept : #TSPLFFEUCBData = "Selected Companies" : CALL : TSPL FFE Update List Variables

    [Part:smsMark]
    Line:smsMarkLn

    [Line:smsMarkLn]
    Field:smsMarkFld

    [Field:smsMarkFld]
    Use:Name Field
    Set as:" "
    Full Width:Yes
    Align:Center
    Color:"Blue"
    Style:sms007
    Read Only:Yes
    Skip Forward:Yes

    [Style:sms007]
    Font:"Times New Roman"
    Height:14

    [Part: TSPL FFE Enable UCB]

    Lines : TSPL FFE Enable UCB, TSPL FFE UCB Path, TSPL FFE UCB Path Info
    Lines : TSPL FFE UCB On, TSPL FFE UCB Data, TSPL FFE UCB Prompt

    [Line: TSPL FFE Enable UCB]

    Field: Long Prompt, TSPL FFE Enable UCB
    Local: Field: Long Prompt : Info : $$LocaleString:"Enable My Backup Feature?"

    [Field: TSPL FFE Enable UCB]

    Use : Logical Field
    Modifies : TSPL FFE EnableUCB : Yes

    [Line: TSPL FFE UCB Path]

    Field: Long Prompt, TSPL FFE UCB Path
    Local: Field: Default : Inactive : NOT #TSPLFFEEnableUCB
    Local: Field: Long Prompt : Info : $$LocaleString:"Destination Path?"

    [Field: TSPL FFE UCB Path]

    Use : Name Field
    Modifies : TSPL FFE DestinationPath
    Set As : If $$IsEmpty:##TSPLFFEDestinationPath Then "E:\Tally Backup" else ##TSPLFFEDestinationPath

    [Line: TSPL FFE UCB Path Info]

    Fields : Simple Field
    Local: Field: Default : Inactive : NOT #TSPLFFEEnableUCB
    Local: Field: Simple Field : Info : $$LocaleString:"(Subfolders for System Date and Time will be created within)"
    Local: Field: Simple Field : Style : Small Italic
    Indent : 1

    [Line: TSPL FFE UCB On]

    Field: Long Prompt, TSPL FFE UCB On
    Local: Field: Default : Inactive : NOT #TSPLFFEEnableUCB
    Local: Field: Long Prompt : Info : $$LocaleString:"Backup On Event?"

    [Field: TSPL FFE UCB On]

    Use : Name Field
    Modifies : TSPL FFE BackupOn
    Table : TSPL FFE BackupOn
    Show Table : Always

    [Line: TSPL FFE UCB Data]

    Field: Long Prompt, TSPL FFE UCB Data
    Local: Field: Default : Inactive : NOT #TSPLFFEEnableUCB
    Local: Field: Long Prompt : Info : $$LocaleString:"Backup Data ?"

    [Field: TSPL FFE UCB Data]

    Use : Name Field
    Modifies : TSPL FFE BackupData
    Table : TSPL FFE BackupData : #TSPLFFEUCBOn CONTAINS "Company"
    Table : TSPL FFE BackupDataAC : #TSPLFFEUCBOn CONTAINS "Tally Application"
    Set As : If $$IsEmpty:##TSPLFFEBackupData Then "All Companies" else ##TSPLFFEBackupData
    Show Table : Always

    ;; Invoke a Sub Form to display list of companies for selection
    Sub Form : TSPL FFE SV Backup : $$Value = "Selected Companies"

    [Line: TSPL FFE UCB Prompt]

    Field: Long Prompt, TSPL FFE UCB Prompt
    Local: Field: Default : Inactive : NOT #TSPLFFEEnableUCB
    Local: Field: Long Prompt : Info : $$LocaleString:"Confirmation from user?"

    [Field: TSPL FFE UCB Prompt]

    Use : Logical Field
    Modifies : TSPL FFE UCBPrompt
    Set As : If #TSPLFFEUCBOn = "Tally Application End" then No Else If $$IsEmpty:##TSPLFFEUCBPrompt Then Yes else ##TSPLFFEUCBPrompt
    Set Always : Yes
    Skip On : #TSPLFFEUCBOn = "Tally Application End"

    ;; Sub Form for List of Companies

    [Report: TSPL FFE SV Backup]

    Use : SV Backup
    Local : Form : SV Backup : Delete : On
    Local : Part : Backup Title : Delete : Lines : Backup Destination
    Local : Part : SV Backup : Set as : $$ListCount:TSPLFFEBackupCompanies
    Local : Field : Backup Name : Delete : Table
    Local : Field : Backup Name : Add : Table : List of All Backup Companies : $$Line = 1
    Local : Field : Backup Name : Add : Table : List of All Backup Companies, End of List : $$Line > 1
    Local : Field : Backup Name : Set As : ##TSPLFFEBackupCompanies[$$Line].Name
    Local : Field : Backup Dest : Set As : ##TSPLFFEBackupCompanies[$$Line].Dest
    Local : Field : Backup Src : Set As : ##TSPLFFEBackupCompanies[$$Line].Src

    ;; Function to update List Variables for Backing up Selected Companies

    [Function: TSPL FFE Update List Variables]

    00 : LIST DELETE : TSPL FFE Backup Companies
    10 : WALKCOLLECTION: BackupCmp
    20 : LIST ADD EX : TSPL FFE Backup Companies
    30 : SET : TSPL FFE Backup Companies[$$LoopIndex].Name : $Name
    40 : SET : TSPL FFE Backup Companies[$$LoopIndex].CompanyNumber : $CompanyNumber
    50 : SET : TSPL FFE Backup Companies[$$LoopIndex].Dest : $Dest
    60 : SET : TSPL FFE Backup Companies[$$LoopIndex].Src : $Src
    70 : END WALK

    ;; Table Definition

    [Table: TSPL FFE BackupOn]

    List Name : "Tally Application Start", "Load Company", "Close Company", "Tally Application End"
    Title : "Backup On Event"

    [Table: TSPL FFE BackupData]

    List Name : "All Companies", "Current Company", "Selected Companies"
    Title : "Backup"

    [Table: TSPL FFE BackupDataAC]

    List Name : "All Companies", "Selected Companies"
    Title : "Backup"

    ;; Variable Definition

    [Variable: TSPL FFE EnableUCB]

    Type : Logical
    Persistent : Yes

    [Variable: TSPL FFE DestinationPath]

    Type : String
    Persistent : Yes

    [Variable: TSPL FFE BackupOn]

    Type : String
    Persistent : Yes

    [Variable: TSPL FFE BackupData]

    Type : String
    Persistent : Yes

    [Variable: TSPL FFE UCBPrompt]

    Type : Logical
    Persistent : Yes

    [Variable: TSPL FFE Backup Companies]

    Variable : Name : String
    Variable : CompanyNumber : String
    Variable : Dest : String
    Variable : Src : String
    Persistent : Yes

    [System: Variable]

    TSPL FFE EnableUCB : Yes
    TSPL FFE DestinationPath : "E:\Tally Backup"

    TSPL FFE BackupOn : "Tally Application End"
    TSPL FFE BackupData : "All Companies"
    TSPL FFE UCBPrompt : No

    List Variable : TSPL FFE Backup Companies

    ; End of Auto backup configuration;
    ; End of Auto backup configuration;

    [System: Event] ;; System Events to take backup on occurence of configured event

    AppStartEvent : System Start : ##TSPLFFEBackupOn = "Tally Application Start" : Call : TSPL FFE Backup Function
    CmpLoadEvent : Load Company : ##TSPLFFEBackupOn = "Load Company" : Call : TSPL FFE Backup Function
    CmpCloseEvent : Close Company : ##TSPLFFEBackupOn = "Close Company" : Call : TSPL FFE Backup Function
    AppEndEvent : System End : ##TSPLFFEBackupOn = "Tally Application End" : Call : TSPL FFE Backup Function

    [Function: TSPL FFE Backup Function] ;; Function checking configured conditions and invoking Backup

    Variable : Backup Det Var: String

    00 : IF : ##TSPLFFEEnableUCB AND ##SVQuitFromRemoteLogout != 1
    10 : IF : ##TSPLFFEUCBPrompt
    20 : QUERY BOX : "Backup Company ?" : Yes:No
    30 : IF : $$LastResult
    40 : CALL : TSPL FFE Backup Company
    50 : ENDIF
    60 : ELSE :
    70 : CALL : TSPL FFE Backup Company
    80 : ENDIF
    90 : ENDIF

    [Function: TSPL FFE Backup Company] ;; Function taking Backup using 'BACKUP COMPANY' Action

    Local Formula : BackUpAllItems : ##TSPLFFEBackupData = "All Companies"
    Local Formula : BackUpCurCompany : ##TSPLFFEBackupData = "Current Company"
    Local Formula : BackUpSelCompanies : ##TSPLFFEBackupData = "Selected Companies"

    00 : SET : SVBackupPath : @@TSPLFFEDestPath
    01 : SET : SVBackupSrc : if $$IsEmpty:##SVBackupSrc then ##SVCurrentPath else ##SVBackupSrc
    05 : SET : BackupDetVar : ##SVBackupPath + ", " + ##SVCurrentPath + ", " + ##SVCurrentCompany + +
    ", " + @@TSPLFFECoNumber
    10 : DO IF : @BackUpAllItems : BACKUP COMPANY:"":$$FullListEx:"":ListofAllBackupCompanies:##SVBackupPath:##SVBackupSrc:$Name:$CompanyNumber
    20 : DO IF : @BackUpCurCompany : BACKUP COMPANY:"," : ##BackupDetVar
    30 : DO IF : @BackUpSelCompanies : BACKUP COMPANY:"":$$FullListEx:"":TSPLFFESelBackupCompaniesSumm:##SVBackupPath:##SVBackupSrc:$Name:$CompanyNumber

    [Collection: TSPL FFE Sel Backup Companies] ;; Collection from List Variables

    Data Source : Variable : TSPL FFE Backup Companies
    Filter : TSPL FFE NonZeroCompany

    [Collection: TSPL FFE Sel Backup Companies Summ]

    Source Collection : TSPL FFE Sel Backup Companies
    By : Name : $Name
    By : CompanyNumber : $CompanyNumber
    Fetch : Dest, Src

    [System: Formula] ;; Formulae constructing Folder and Sub Folder Path for Backup File

    TSPL FFE DestPath : ##TSPLFFEDestinationPath + "\" + @@TSPLFFEDateForm + "\" + @@TSPLFFETimeForm
    TSPL FFE CoNumber : $$String:($CompanyNumber:Company:##SVCurrentCompany):5
    TSPL FFE DateForm : $$String:mad:@TSPLFFESysDate
    TSPL FFE TimeForm : @@TSPLFFEHrsForm + @@TSPLFFEMtsForm

    TSPL FFE HrsForm : If $$StringPart:mad:@TSPLFFESysTime:0:2 CONTAINS ":" +
    Then $$StringPart:mad:@TSPLFFESysTime:0:1 +
    Else $$StringPart:mad:@TSPLFFESysTime:0:2

    TSPL FFE MtsForm : If $$StringPart:mad:@TSPLFFESysTime:0:2 CONTAINS ":" +
    Then $$StringPart:mad:@TSPLFFESysTime:2:2 +
    Else $$StringPart:mad:@TSPLFFESysTime:3:2

    TSPL FFE SysDate : $$SysInfo:SystemDate
    TSPL FFE SysTime : $$SysInfo:SystemTime

    TSPL FFE NonZeroCompany : $CompanyNumber != "0"

    ;; End-of-File
     
    Last edited: Aug 6, 2020


  2. Adarsh Aggarwal

    Adarsh Aggarwal New Member


    Giving error in the code as under:
    TSPL FFE HrsForm : If $$StringPart:mad:@TSPLFFESysTime:0:2 CONTAINS ":" +
    Then $$StringPart:mad:@TSPLFFESysTime:0:1 +
    Else $$StringPart:mad:@TSPLFFESysTime:0:2

    TSPL FFE MtsForm : If $$StringPart:mad:@TSPLFFESysTime:0:2 CONTAINS ":" +
    Then $$StringPart:mad:@TSPLFFESysTime:2:2 +
    Else $$StringPart:mad:@TSPLFFESysTime:3:2

    Please guide us for correction of code
     


  3. abhinand vk

    abhinand vk Active Member


    this will work
     

    Attached Files:

    mpal2311 likes this.


  4. mpal2311

    mpal2311 Active Member


    Good One.
     


  5. Sudin Ghosh

    Sudin Ghosh New Member


    Sir TDL loaded but in F12 there is no command for"K" or Backup.

    Please suggest
     


  6. abhinand vk

    abhinand vk Active Member


    so
    sorry sudin gosh please change first two line

    [#Menu: Gateway of Tally ] ;; Adding a Menu Item to Configure My Backup - F12 -> My Backup

    Add : Key Item : After : @@locquit : "My Backup" : K : Execute : TSPL FFE UCBConfig

    To
    [#Menu:Configuration]
    Add : Key Item : Before: @@locEmail : "My Backup" : K : Execute : TSPL FFE UCBConfig

    then this will work on f12 Configuration
     


  7. Sudin Ghosh

    Sudin Ghosh New Member


    sir F12 configuration it comes , I command the selected drive and accept but backup not done please check this issues
     

    Attached Files:



  8. ag_1234

    ag_1234 New Member


    D



    Dear Sir,

    I recommend using Cobian Backup utility and take back up of complete tally data folder once in a day, creating multiple backups on daily basis will consume more storage space on your system. cobian backup s a utility which can be secheduled any time that you want and are comfortable. Back will also be created even if the tally is being used at the time of backup running. I use same if required will share settings with you.

    Regards
     


  9. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Second Copy is also similar utility and provides many options also.
     


  10. Sudin Ghosh

    Sudin Ghosh New Member


    Thanks sir, for sending me the copy but back up getting always overwrite and not done in specific destination which i give f12 configuration ,it is creating a automated folder in d drive and and make a folder name demo.
    Please give me some perfect coding.that I can take it on my desired path given and not overwrite the back up every time.
     


  11. abhinand vk

    abhinand vk Active Member


    Also, I suggest you refer the default samples for Auto Backup.

    Also for system events, you can refer the default samples under Tally.Developer9SamplesWhats NewRel 2.xRel 2.0Event Framework ChangesTimerUser Configured BackupUser Configured Backup.txt
     


Share This Page