Alpha DevCon 2018
Results 1 to 5 of 5

Thread: Mask Problem

  1. #1
    Member
    Real Name
    David Katz
    Join Date
    Apr 2000
    Posts
    291

    Default Mask Problem

    We want to run a update field with giving recno but we want it always 4 digit so recno 1 = 0001 how can we do it?

  2. #2
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,907

    Default Re: Mask Problem

    I do not believe it can be done as recno() is numeric and as far as I can tell, anytime a number has leading zeros they are automatically trimmed. Converting to character, however, makes it as easy as:


    Code:
    dim x as c
    dim cnum as c
    cnum=1
    x=padl(cnum,4,"0")
    
    ?x
    = "0001"
    If starting from numeric then use the str() function to first convert to character.

    Only thing I can think of...maybe others will drop by and I will learn something new!! :)
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  3. #3
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,299

    Default Re: Mask Problem

    David,

    The following expression can be used in a saved UPDATE OPERATION to assign each record's physical record number to a character type field in the same table. In this case the table being updated is called "Workouts".

    Code:
    padl(ltrim(str(recno("workouts"),4)),4,"0")
    Interpreting this from the "innermost" function to the "outermost" function you can see that:

    a) first the physical record number is obtained
    Code:
    (recno("Workouts")
    b) then the physical record number is converted to character string of length 4
    Code:
    (str(recno("workouts"),4)
    c) then the leading blanks in the new character string are trimmed off
    Code:
    ltrim(str(recno("workouts"),4))
    d) and finally, the resulting string is padded on the left with leading zeros
    Code:
    padl(ltrim(str(recno("workouts"),4)),4,"0")
    Check the help file discussion for an important warning about the use of the RECNO() function. It should not be used as an identifier for records in your table.

  4. #4
    Member
    Real Name
    David Katz
    Join Date
    Apr 2000
    Posts
    291

    Default Re: Mask Problem

    how do we put together all these codes?

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,008

    Default Re: Mask Problem

    Tom showed you the steps one might use to arrive at the final necessary expression...

    Code:
    padl(ltrim(str(recno("workouts"),4)),4,"0")
    This is all you need.

Similar Threads

  1. mask problem
    By Parish Mills in forum Alpha Five Version 8
    Replies: 1
    Last Post: 07-24-2008, 09:28 AM
  2. need help regarding mask
    By adamry in forum Alpha Five Version 8
    Replies: 17
    Last Post: 11-19-2007, 06:16 PM
  3. Mask problem
    By Dave Mac Callum in forum Alpha Five Version 7
    Replies: 23
    Last Post: 12-01-2006, 10:57 AM
  4. Mask
    By russ Boehle in forum Alpha Five Version 5
    Replies: 0
    Last Post: 03-25-2003, 11:44 AM
  5. Simple Mask Problem
    By Richard Constantine in forum Alpha Five Version 4
    Replies: 2
    Last Post: 10-10-2001, 02:53 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •