This discussion is archived
8 Replies Latest reply: Jun 17, 2013 2:51 PM by 1006415 RSS

Documaker Field alignment

1001662 Newbie
Currently Being Moderated
I am busy developing forms where all the fields have to be centre aligned.

For the fields where I derive the data directly from the XML input, I can easily do this using the JUSTFLD, MODE=C rule. I am struggling to centre align the fields where I use a call to DAL to populate the fields.

The max length of these fields can be anything from 1 - 60 characters, and even though I centre page aligned the field box, it still left aligns the field outputs.

I have tried JUSTFIELD amd JCENTER inside the DAL script but without success.

How do I centre align a field value dynamically for values populated from a DAL script ?

Edited by: 998659 on 2013/04/08 3:47 AM

Edited by: 998659 on 2013/04/08 8:42 AM
  • 1. Re: Documaker Field alignment
    user9976634 Journeyer
    Currently Being Moderated
    You may have to include an example of your script to help determine the exact cause, because the DAL function JustField() uses the same internal APIs as the rule you have used successfully.

    The key to remember is that the JustField function operates at the moment of call. So if your script returns a value to the field in PostEdit that is different than what was there when you called JustField(), you could get unbalanced results.

    In a Post edit on a field, all you would need to do is JustField('C') as the last statement in the script. This will center the "current" field.

    If on the other hand you are trying to assign values into fields an then justify them from some other script location, you need to include enough parameters to locate the appropriate field. So you might do something like this:

    SETFLD("Abc123", "MyField")
    JustField('C', , , "MyField")

    In this case, you will note that there are two omitted parameters. The second parameter is a horizontal location to center upon and the third is for a character (like decimal) justification. I'm assuming that you are designing your fields in the appropriate location and you just want to center them there.

    And by the way JCENTER() would only justify appropriately if you are using a fixed-pitch (like Courier) font. JCENTER simply takes the overall field length and pads the data with spaces so that you are centered in "character length" not "display length". If you are using proportional fonts (where each character is a different width), you will need JUSTFIELD().
  • 2. Re: Documaker Field alignment
    1001662 Newbie
    Currently Being Moderated
    Thanks for the reply, but I am still unable to get the desired result.

    Here is an example of my script:

    *********************************
    NormalLegal = getdata("!/letterContent/registrationForm/derivedData/businessType 1,45")
    AmendLegal = getdata("!/letterContent/registrationForm/derivedData/amendmentData/legalName 1,45")

    If len(AmendLegal) = 0
    LegName = NormalLegal
    JustField('C')
    Return(Legname)

    Else
    LegName = AmendLegal
    JustField('C')
    Return(Legname)
    End

    ********************************

    I then call this DAL script under File Options in Studio.

    I do manage to get this right when using the JUSTFLD rule with the following:

    !/letterContent/registrationForm/derivedData/businessType MODE=C, RULE=MOVE_IT


    Unfortunately I have to make use of the DAl script to apply the required logic (the source values can reside in one of two locations in the XML)
  • 3. Re: Documaker Field alignment
    user9976634 Journeyer
    Currently Being Moderated
    This appears to fall into the scenario I mentioned regarding timing. You see, at the time you are executing this script, you are in the field rule for the field in question and is expected to "return" the value you want assigned to the field. So at the point where you call JustField() in your script, your field has NO data assigned. That is why you do not get what you expect.

    Try amending your script like this:

    *********************************
    NormalLegal = getdata("!/letterContent/registrationForm/derivedData/businessType 1,45")
    AmendLegal = getdata("!/letterContent/registrationForm/derivedData/amendmentData/legalName 1,45")

    If len(AmendLegal) = 0
    LegName = NormalLegal
    Else
    LegName = AmendLegal
    End

    SetFld(Legname)

    JustField('C')
    Return(Legname)

    ********************************

    This first ensures that the field value is assigned via SETFLD. Then the following attempt at justification has the proper value to work with in the field. You still want to return the value, because if you return nothing, the field mapper will likely clear out what you had previously assigned.
  • 4. Re: Documaker Field alignment
    1001662 Newbie
    Currently Being Moderated
    Works like a charm !!! Thanks for the assistance.
  • 5. Re: Documaker Field alignment
    user9976634 Journeyer
    Currently Being Moderated
    You are welcome.
    I forgot one other thing I was going to mention. You can actually use DAL from the JustFld rule as well.

    So where you previously doing something like this:

    !/letterContent/registrationForm/derivedData/businessType MODE=C, RULE=MOVE_IT

    You could do something like this:

    MyDal MODE=C, RULE=DAL

    Then your script simply has to return the expected value. I've rewritten to offer some minor efficiency.

    *********************************
    LegName = getdata("!/letterContent/registrationForm/derivedData/amendmentData/legalName 1,45")
    if (LEN(LegName) = 0)
    LegName = getdata("!/letterContent/registrationForm/derivedData/businessType 1,45")
    end

    Return(Legname)

    ********************************

    I'm not suggesting that one method is better than the other. I just wanted to point out that you can use DAL from the JustFld rule. I forgot to mention that before.
  • 6. Re: Documaker Field alignment
    user9976634 Journeyer
    Currently Being Moderated
    Sorry, I think the MyDal shoudl have been MyDAL() presuming that your script is a routine from a script library. If it is a stand-alone script, then you could do:
    CALL( "MyDal" )

    I'm not really trying to confuse. I just wanted to be complete.
  • 7. Re: Documaker Field alignment
    mchurichi Newbie
    Currently Being Moderated

    Sorry for use the thread, but that's exactly my problem.

    I'm retrieving the data from the XML through DAL and I want my field centered, but I'm getting it left aligned.

    This is the field on my section:

     

    Rule: JUSTFLD

    Data: Return(Trim(GetData("!//PATH/TO/VAR[@CLASS='SOMECLASS'][@TYPE='SOMETYPE']/@VALUE 1,100"))) MODE=C, XPOS=10000, RULE=DAL

     

    The DAL is working fine, using just the DAL rule it's working right.

     

    Where could be the problem?

    Can be achieved this way or should I set the field and make the alignment through DAL scripting?

     

    Thanks,

    Max

  • 8. Re: Documaker Field alignment
    1006415 Newbie
    Currently Being Moderated

    Try this in your field entry:

     

    Rule: MOVE_IT

    Mask: C

    Data: !//PATH/TO/VAR[@CLASS='SOMECLASS'][@TYPE='SOMETYPE']/@VALUE

     

    Let me know how it goes.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points