Need to Trim value in a List

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Need to Trim value in a List

    I have a list that retrieves documents in a directory. <!--- Pack Directory
    ---> <cfdirectory action='list' directory='C:\TNS_Docs\EXCEL_PACKS' sort='type
    asc' name='directory_listing'> I then have a query that checks if a user has
    access to documents dependant on the first 3 numbers of the documents, i then
    want to match them up and show them to the user. I need to trim the NAME value
    in the DIRECTORY_LISTING so i only look at the first 3 numbers. <!--- My Query
    ---> <cfquery name='mylist' dbtype='query'> select name, size,
    datelastmodified from directory_listing where name =
    '#GET_DATA.pack_location#PACK.xls' </cfquery> Everytime I use LEFT(name, 3) I
    get an error. Any ideas?

    craig_uk Guest

  2. Similar Questions and Discussions

    1. trim function
      Hi there, does any know how i can do a 'trim on canvas' sort of function. If my canvas is bigger than my draw/animation etc, then how do i shrink...
    2. Trim problem
      Hi, i have another complex problem i cannot figure out. I have a string called #file_name#. The string's value is a filepath and file name of a...
    3. Trim Text Along a Path
      I am trying to take a single letter that needs to be trimmed to fit within a circle. Essentially I want to replicate this image that I did in...
    4. Sizing trim marks
      Is it possible to change the default stroke, offset and length of trim marks created with the trim marks filter?
    5. trim string
      How do i cut the last 4 characters in a string? I know how to cut the 4 first, but i need to cut the last! I have a image name like testimage.gif...
  3. #2

    Default Re: Need to Trim value in a List

    craig_uk, the Query of Queries doesn't support every SQL statement. In fact,
    it does support very little of them. (the LEFT() statement isn't one of them!)
    But in regard to your problem, what do you think about turning your routine
    around? Instead of getting all the files and then checking if a user may see
    them, you could get only those files which the user may see. You have a query,
    GET_DATA, with pack_location to indicate what packs the user may see, am I
    right? You could use that GET_DATA.pack_location as a filter in your
    cfdirectory tag, so it only gets those files who meet this filter. Like so:
    filter='#GET_DATA.pack_location#*' Hope that helps.

    pukkel Guest

  4. #3

    Default Re: Need to Trim value in a List

    Thanks for the reply. I've created a test script based on what you said.
    <CFQUERY NAME='GET_DATA' datasource='TNS'> SELECT p.pack_location FROM
    Users_tbl u, Pack_data_tbl p where u.user_id = 164 AND u.user_id = p.user_id
    order by p.pack_location </CFQUERY> <cfdirectory action='list'
    directory='C:\TNS_Docs\EXCEL_PACKS' sort='type asc' name='directory_listing'
    filter='#get_data.pack_location#*'> <cfloop query='GET_DATA'> <cfdump
    var='#directory_listing#'> </cfloop> I should get 2 files showing yet I get
    none. ? Cheers

    craig_uk Guest

  5. #4

    Default Re: Need to Trim value in a List

    You have misplaced the cfdirectory tag, it should be within the cfloop..
    Because I see now that users can have rights to multiple, different 'packs';
    you should take into account that the cfdirectory tag only supports one filter
    at a time (too bad, I think). Therfore it should be within the loop where you
    output the packs.

    pukkel Guest

  6. #5

    Default Re: Need to Trim value in a List

    That works, thanks for the pointers. <CFQUERY NAME='GET_DATA'
    datasource='TNS'> SELECT p.pack_location FROM Users_tbl u, Pack_data_tbl p
    where u.user_id = 164 AND u.user_id = p.user_id order by p.pack_location
    </CFQUERY> <cfloop query='GET_DATA'> <cfdirectory action='list'
    directory='C:\TNS_Docs\EXCEL_PACKS' sort='type asc' name='directory_listing'
    filter='#get_data.pack_location#*'> <cfoutput query='directory_listing'>
    #name#<br> </cfoutput> </cfloop>

    craig_uk Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139