Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)

by Loops (Curate)
on Nov 18, 2014 at 16:41 UTC ( #1107594=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)
in thread Perl6::Form Issues with Zero-Padding and Declarative Width

Hey there,

Glad you got it mostly sorted out and working. I'm sorry that my quick attempt to help was off the mark. But it did relate to your outstanding question about declarative field widths. Maybe this will help:

Declarative field widths add no formatting information. The field you were talking to Damian about was this:

{>>>>>}

Clearly a field of 7 characters. There is no other information in order for this field to be used at this point. If in addition, you want an automatically validated "checksum" to ensure that the field is actually the width you intended, you can add it as a length inside parentheses:

{>(7)>}

The field is still 7 characters long, just as before. The form code will rip the "(7)" out, validate that the 7 matches the actual field length, and then logically replace it with ">>>" to restore the real format.

None of this is very useful for a field of 7 characters, it can be eyeballed as correct pretty easily. But for a field of say 50+ characters, it's nice to have a double check.

Replies are listed 'Best First'.
Re^4: Perl6::Form Issues with Zero-Padding and Declarative Width (integer)
by AnaximanderThales (Novice) on Nov 18, 2014 at 19:27 UTC
    No worries --

    The issue that I'm having with the declarative width is how '7' is arrived (I use 7 now, but I'll clarify in a moment).

    Since I'm wrapped up in trying to get my project in a state that I'm satisfied with right now so I haven't played with this more, so I can't say for certain this occurred.

    We have {>>>>>} which is 7 characters. We have {>(5)>} which is also 7 characters? Okay -- I'll accept that the {} are included in the count. In my mind, while I was playing with things, I remember switching {>(5)>} to {>(3)>}. This should be 5 characters. When I have " 003," I should not get the validation error. My data has 5 characters, the field is 5 characters.

    Like I said, I haven't gone back and tested it, it was one iteration out 20 or 30 tries. So, this is what I need to bang around with and figure out. I just need more experience with it, break what I'm doing, ask more questions and just get it set in my mind with my own words.

      Ah, I see the source of confusion. I think you're mixing up Imperative field widths with what you're using, Declarative field widths.

      Here's another field specification example to make things clear:

      {>>>>>>>>>>>>>>>>>>}

      That is a field of 20 characters. That's the actual specification, no "(20)" in there at all. Adding the "(20)" doesn't change the width at all.. if you put in a "(7)" it wouldn't change the width either. But when the form is validated, the first one would pass, and the second would generate an error. This has nothing to do with _setting_ the width of the field, only validating that you've typed it in correctly with no missing or added characters.

      Now if you don't want to type all those characters you can use the Imperative field width syntax using curly brackets:

      {>{20}>}

      This forces the field width to be 20 characters wide, so it is another way that has duplicate functionality to the first example.

      HTH.
        I believe it makes sense now.

        {>(20)>} generates an error because it's not {>>>>>>>>>(20)>>>>>>>>>}?

        {>>>(7)>>} doesn't generate an error?

        The Parens'd value is a validity of the bracketed field as opposed to the value that will be presented at run time? Am I correct?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1107594]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2021-04-22 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?