how to set the font name dynamically? help

Discussion in 'Tally Developer' started by puzzle, Jun 30, 2018.

    
Tags:
  1. puzzle

    puzzle New Member


    hello experts
    i am not able to set the font name dynamically from my custom udf as it prompts and error of memory access violation how to solve this issue,
    kindly help

    thanks in advance
     


  2. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    [Style : MyStyle]
    Font : if <your condition> then "Verdana" else "Helvetica"
    Bold : No
    Height : 9

    Refer Styles.tdl..............for other fonts.......
     


  3. puzzle

    puzzle New Member


    THANKS FOR THE REPLY,
    BUT,
    SIR I AM TAKING USER INPUT IN MY UDF FIELD AND AS PER THAT UDF I NEED TO SET THE FONT NAME ,
    THAT I AM NOT ABLE TO DO
    I TRIED USING THE FOLLOWING CODE BUT GOT MAV ERROR IF MAD THE COMPANY NAME DYNAMIC
    [Style:big font]
    Height:"10";$$Number:$FONTH:company:DEMO;##svcurrentcompany;$$LocaleString:$NAME;$NAME;##svcurrentcompany28
    Bold:IF ##BOLDY THEN YES ELSE NO
    Font Name :"ARIAL";$$CollectionFieldByKey:$FONT:1:AA;"ARIAL";$FONT:company:$$LocaleString:$NAME;$NAME;##svcurrentcompany;$$CollectionField:$FONT:1:AA;$FONT:company:$NAME;##SVCurrentCompany;Bookman Old Style
    ; Replace:Font:$$LocaleString:$FONT:COMPANY:$BasicCompanyFormalName;##svcurrentcompany
    ;Replace:Height:$$Number:$FONTH:company:DEMO;##svcurrentcompany
     


  4. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    what is FONTH? and what is BOLDY??

    Can't understand your code....so when you put a post...select INSERT...then select CODE and then put your code.....so it can be understood.

    And kindly remove unwanted code snippets.......
     


  5. puzzle

    puzzle New Member


    THANKS FOR GUIDING

    sir , the basic requirement is that , i am adding a udf to store the customer preference font ,
    that font i am trying to replace with font declared in the [style] but when i am setting the udf using method formula or collection i am getting error of memory access violation,but when i am hardcodeing the company name in method formula then i am getting the result,
     


  6. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Good...it is working out......cheers......
     


  7. puzzle

    puzzle New Member


    Code:
    ;;added a udf in print conf
       
    [#Part: IPCFG Title]
    
      delete:  Lines  : SATitle, SAOptTitle, SASubTitle, SACompLogo, SALogoPath
      add:Lines  : SATitle, SAOptTitle, SASubTitle, SACompLogo, SALogoPath,LINE3
      Space Bottom  : 0.5
      Horizontal Align  : Centre   
       
    [Line:LINE3]
      Field: long Prompt, F3
       Local: Field: long Prompt: Set as: "SET FONT NAME FOR HEADER:"
    
    [Field:F3]
      Use:ShortNameField
      Set as:"Lucida Handwriting";$$CurrentSimpleCompany
      ;Storage:FONTnames
      ;Set Always:Yes
      Modifies:FONTnames:yes
       
    [Variable: FONTnames]
    
      Persistent  : Yes
      Type  : String
    
       
    [System:UDF]
      FONTnames:String:1312
    
    ;;;;;;modified font
    
    
    [Field: Name Fieldd]
    
      Width  : @@NameWidth
      Max  : @@MaxNameWidth
      Style  : Normal Boldd
      Case  : Title Case
      Print BG  :red
    
    [Style: Normal boldd]
      Font:$$LocaleString:##FONTnames;if $$CurrentCompany then ##FONTnames else "arial"
    
    [#Line: EXPINV Consignee]
      Field  : Name Fieldd
               Local  : Field : Name Fieldd : Set as : @@ConsigneeName
      Local  : Field : Name Fieldd : Width  : 50% Page
               Local  : Field : Name Fieldd : Cells  : 2 * ($$Quotient:@@ExcelCellColumn:4)
    
    
    sir this is the code kindly check and help,
    i have added a udf in printing config
    and that value i am setting to font but it gives error of mav
    kindly help

    regards
     
    Last edited: Jul 1, 2018


  8. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Here is the revised code..........

    I tried manually putting font names....but the print does not change...it takes the default font..... means this TDL is not able to override the Font setting....and due to clash...it is showing MAV error.

    However i have given you alternative to highlight the same.... find the attached code.

    Code:
    [#Part : IPCFG Title]
        add : line : line3
    
    [Line : LINE3]
        Field : medium Prompt, F3
           Local : Field : medium Prompt : Set as    : "Select Font for Header:"
           Local : Field : medium Prompt : color    : blue
           Local : Field : medium Prompt : style    : normal bold
    
    [Field : F3]
          Use : Name Field
          Table        : ListofFont, Endoflist
          show table    : always
          Storage        : FONTnames
          Set Always    : Yes
          Modifies    : FONTnames:yes
    
    [Table : ListofFont]
        Title        : "List of Fonts"
        List Name     : $$LocaleString:"Calibri", $$LocaleString:"Helvetica", $$LocaleString:"Arial", $$LocaleString:"Times New Roman", +
                    $$LocaleString:"Times", $$LocaleString:"Verdana", $$LocaleString:"Book Antiqua", $$LocaleString:"Courier New", +
                    $$LocaleString:"Wingdings 2", $$LocaleString:"Algerian",
        Format        : $Name,25
        Client Only    : Yes
      
    [System : UDF]
          FONTnames     : String : 1312
    
    [Style : myNormalboldd]
          Font         : $FONTnames
          Height         : 10
        Bold        : Yes
    
    [#Line : EXPINV Consignee]
        Field : Name Field
        Local : Field : Name Field     : Print BG     : Grey
        Local : Field : Name Field     : Print FG     : Red
    ;    Local : Field : Name Field     : Style        : myNormalboldd
    
    
     


  9. puzzle

    puzzle New Member


    still there is the error of mav
     


  10. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Copy paste my code ..as it is.... i am not showing error of MAV

    see below screenshot

    Capture.PNG
     


  11. puzzle

    puzzle New Member


    sir you have commented the style tag ,enable it and check the font is not changing
     


  12. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    obviously...if u read it properly first time,,,that what i meant........so please read it slowly and patiently and u will understand...............

    I said in my post.... that FONT is not being able to override...and i have given you alternative...
     


Share This Page