Alpha Video Training
Results 1 to 12 of 12

Thread: problem/w character strings:

  1. #1
    Member
    Real Name
    Mac McIntosh
    Join Date
    Dec 2002
    Posts
    38

    Default problem/w character strings:

    Hello again all,

    I know someone out there can do this! I will try and explain as fully as possible.

    I have a field in a db that contains names. (ex: "John Doe - "Betty doe" - "Ralph Doe") As you can see, each name is seperated by "-". In this db I have 178 rcrds with anywhere from 1-3 names at a time in said field. I'm trying to get a list of names from this field, that are not duplicated and contain no blanks. (Use an array or collection - right!) Well, I have attempted both, but cannot get a list/w just a single name not dup'd. I know we can sort A-Z, and that's what I'd like when I get the list? It's just with so many names and remember, the field can contain the same name again and again. That's where the problem is. Is anyone interested?

    Thanks,
    Mac

  2. #2
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default RE: problem/w character strings:

    Mac,

    Did you mean to include double quotes within the the field value (around every name)? Assuming not, the code below at least singles out unique names for the field as a starting point.

    fld = "John Doe - Betty Doe - Ralph Doe"
    ?keywords(strtran(fld,"-",""))
    = "Betty Doe John Ralph"

    Other code using WORD() functions and the like could maybe be used to parse it down further.

    I'm curious as to how this field gets generated. If it's exported from a remote source that's understandable. But if you designed it as such, you should consider using multiple child records rather than concatenating the names together as such.

    Steve

  3. #3
    Member
    Real Name
    Mac McIntosh
    Join Date
    Dec 2002
    Posts
    38

    Default RE: problem/w character strings:

    Steve,

    Actually I imported from Excel, but anyways, no there is not "" around every name. What I need to do is seperate the names to a list and then sort A-Z. The problem is, each record has the same name repeated again (not always, but)and it's difficult sorting thru each record - pulling out a new name (not one that's already in 'mylist' for ex)and adding it to(mylist). What will eventually happen Steve, is I will print a report for each record that a particular name is linked too. Some have 5-10 and some may only have 1. I hope I explained this a little better? It sure has my mind all twisted. :-)

    Mac

  4. #4
    Member
    Real Name
    Mac McIntosh
    Join Date
    Dec 2002
    Posts
    38

    Default RE: problem/w character strings:

    Steve,

    I'm sorry, but maybe this will help. The db is an application that keeps track of DVD movies. What I'm trying to do is sort out the actors/actress's and then print a report on what movies they acted in.

    Does that help a little better?

    Thanks,

    Mac

  5. #5
    "Certified" Alphaholic Tom Henkel's Avatar
    Real Name
    Tom Henkel
    Join Date
    May 2002
    Location
    New Jersey, USA
    Posts
    1,877

    Default RE: problem/w character strings:

    Using this field as a base, why not build an indexed table of the names. Stripping them out one by one, using the name as an index. When building the table, don't allow duplicates.

    Preventing duplicate on a name field can be dangerous as there certainly can be multiple "John Smith"s in the world.

    Instead of building the concatenated field from excel, why not just import into a new table cell by cell.

    Tom

  6. #6
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default RE: problem/w character strings:

    Mac,

    I see now that by "name" you were referring to full names. If I understand your problem correctly, some code as follows may do:

    dim arr_nam(600)as C
    dim cntr as N
    dim names as C
    dim name1 as C
    cntr = 0
    tbl=table.open("tablename")
    tbl.fetch_first()
    while .NOT. tbl.fetch_eof()
    names=tbl.field_name
    for j=1 to w_count(names)
    name1 = alltrim(word(names,j,"-"))
    if arr_nam.find(name1)=0
    cntr=cntr+1
    arr_nam[cntr]=name1
    end if
    next j
    tbl.fetch_next()
    wend
    arr_nam.sort()
    tbl.close()

    This would add unique names to your array and then sort them.

    Steve

  7. #7
    Member
    Real Name
    Mac McIntosh
    Join Date
    Dec 2002
    Posts
    38

    Default RE: problem/w character strings:

    Steve,

    That's great - but can I ask probably a stupid question here, but my brain is fried. Is there anyway to get rid of those 358 blank lines in front of the list? I was thinking maybe some way of 'Dimming' the array with the exact number of names in the list? Do you think so?

    Mac

  8. #8
    Member
    Real Name
    Steve Andrews
    Join Date
    Jan 2004
    Location
    Mahwah, NJ
    Posts
    644

    Default RE: problem/w character strings:

    Mac,

    Is there anyway to get rid of those 358 blank lines in front of the list?

    I assume by "blank lines" you are referring to array elements? Why would you want to limit the array size? Just dim it with more elements than you would ever need. If the counter variable (cntr) is still in scope, simply use the first cntr elements of the array thereby ignoring these "blank lines". If the counter is no longer available, redetermine it as:

    name_cnt = arr_nam.first_empty() - 1

    Steve

  9. #9
    Member
    Real Name
    Mac McIntosh
    Join Date
    Dec 2002
    Posts
    38

    Default RE: problem/w character strings:

    Steve,

    Thanks a bunch for the help! I'm still a learner in the field of programming Steve. Arrays still bogle my mind sometimes. Sure appreciate all that you guys/gals do here on the forum. It's great to have a little help so quick and easy!

    Thanks Again -

    Mac

  10. #10
    Member
    Real Name
    Mac McIntosh
    Join Date
    Dec 2002
    Posts
    38

    Default RE: problem/w character strings:

    Tom,

    I only imported once from excel. I was using it to keep track when all-of-sudden, BINGO, I got a brain storm using AlphaFive. Now ain't that peculiar. :-)

    Actually Tom, I thought about indexing, but man would that be a huge file. At least I think so? What would be your idea on a way to index? It would have to match the movie title/w the actor/actress. Any ideas are truly welcome! I learn more about Alpha off this forum than I think I would learn at a - well you know what I mean.

    Thanks Bunch Tom
    Mac

  11. #11
    "Certified" Alphaholic Tom Henkel's Avatar
    Real Name
    Tom Henkel
    Join Date
    May 2002
    Location
    New Jersey, USA
    Posts
    1,877

    Default RE: problem/w character strings:

    Now you've piqued my interest. (That can be dangerous)

    What about a simple set? Two tables, Films, and actors.

    Films could have information about each movie, 1 record per film.

    Actors will be my name, with an additional field for a movie. There would be multiple records per actor 1 for each film they were in.

    Now build 2 sets.
    FILM
    |==="Actor

    Linking field is Film title.

    Actor
    |==="FILM
    Linking field is FILM Title

    Now, if you use set 1, you can find all actors in a film, and using set 2, you can find all films that an actor was in.

    See what happens when I get interrested??

    Tom

  12. #12
    Member
    Real Name
    Mac McIntosh
    Join Date
    Dec 2002
    Posts
    38

    Default RE: problem/w character strings:

    Tom,

    Sorry about taking so long to get back at you :-(
    I was out of town yesterday - but anyways - good idea! I shall ponder on that approach. But I want to try printing these reports by actor first. If it doesn't work - I think you plan is definetely positive!

    Thanks,

    Mac

Similar Threads

  1. Chinese Character Problem on a5w Pages
    By KKH in forum Web Application Server v6
    Replies: 10
    Last Post: 04-03-2008, 07:58 PM
  2. Cannot Enter Certain Strings
    By Steve Andrews in forum Forum Usage
    Replies: 2
    Last Post: 09-27-2005, 11:44 AM
  3. Character field problem
    By Art Cordaro in forum Alpha Five Version 4
    Replies: 2
    Last Post: 02-10-2005, 03:29 AM
  4. Zero Length Strings?
    By Bill Walker in forum Alpha Five Version 5
    Replies: 18
    Last Post: 01-30-2004, 04:36 AM
  5. Expressions for extracting character strings
    By Hal Smith in forum Alpha Four Version 6 and Prior
    Replies: 7
    Last Post: 01-10-2001, 08:59 PM

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
  •