Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Re: Checking for string output duplicity... (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Where are plugins and classes?
Next thread: Re: RealDatabase Quirks


Re: Checking for string output duplicity...   -   Rick Davis
  Re: Checking for string output duplicity...   -   Frank Bitterlich
   Re: Checking for string output duplicity...   -   Richard Davis
  Checking for string output duplicity...   -   Rick Davis
   Re: Checking for string output duplicity...   -   Joseph J. Strout

Re: Checking for string output duplicity...
Date: 01.08.03 04:53 (Thu, 31 Jul 2003 23:53:51 -0400)
From: Rick Davis
Heylo again,

I've tried to work through Joe's response below with both REALbasic for
Dummies and REALbasic the Definitive Guide by my side. But I'm just
not getting it. I had a colleague try to show me how he would do it in
Java. I'll wrestle with that for a day or two. In the mean time if
anyone has the time to write some simple instructions that might point
me in the right direction I would appreciate it.

I am developing an application that will use a tab-delimited text file
to generate an XML file that will be used to import users and groups
into a Mac OS X Server. The user can choose to put the shortName in the
third field of a tab-delimited text file and then import that shortName
directly. Or they can choose to generate the shortName using from 0-9
characters of the first field (first name) and 0-9 characters of the
second field (last name) of the tab-delimited text file. They also
have the choice of using the last name then the first name for the
generated shortName. What I am trying to do is compare the shortName
as it is being written to my textoutput file (whether imported or
generated) to the list of shortName's and if the shortName is already
used then the last character is changed to the number one, if shortNam1
is already used then the last character should be changed to two,
shortNam2.

This is a sample of the code used to determine the shortName written:

--------------
dim shortName,impShortName,gen1ShortName,gen2ShortName as string

if snSel.text="isn" then
shortName=impShortName
elseIf snSel.text="gsn" then
if snFormat.text="fnln" then
shortName=gen1ShortName
elseIf snFormat.text="lnfn" then
shortName=gen2ShortName
end
end
--------------

Right now I have to spend extra time reviewing either the tab-delimited
file beforehand or the XML file afterwards to eliminate duplicate
shortNames.

Hope this makes sense to someone.

Thanks and Have A Great Day.

Rick Davis

On Wednesday, July 30, 2003, at 11:20 AM, Joe wrote:

> Subject: Re: Checking for string output duplicity...
> From: "Joseph J. Strout" <<email address removed>>
> Date: Wed, 30 Jul 2003 07:20:09 -0700
>
> At 7:37 AM -0400 7/30/03, Rick Davis wrote:
>
>> My problem is what to do when I have Michelle Anderson, Michael
>> Anderson and Mickala Anderson all in the same list (real people in a
>> local school). Mac OS X does not allow duplicate short names and
>> they would all be andermic. I would like my app to compare the
>> short name generated and if a duplicate change the last character to
>> a number 1, 2, etc as needed.
>
> Well, you've pretty well described it:
>
> while NameAlreadyUsed(name)
> name = Left(name, Len(name) - Len(str(num))) + str(num)
> num = num + 1
> wend
>
> Cheers,
> - Joe
>
> --
> ,------------------------------------------------------------------.
> | Joseph J. Strout REAL Software, Inc. |
> | <email address removed> http://www.realsoftware.com |
> `------------------------------------------------------------------'
>
> ----------------------------------------------------------------------
>

Original post

Subject: Checking for string output duplicity...
From: "Rick Davis" <<email address removed>>
Date: Wed, 30 Jul 2003 07:37:36 -0400

Heylo All,

Very new to RB and programming in general (well, some HTML and XML), so
I may not even ask the question right but will try.

I have written an app that will create an XML file that can then be
imported into Mac OS X Server from a tab-delimited file by importing or
generating the necessary data from two to seven fields. One of the
tasks is to generate a user short name from two fields (first name,
last name) based upon the number of characters assigned by the user.
For instance if the first name is Michelle and the last name is
Anderson; the user asks to generate the short name using the first five
characters of the last name and the first three letters of the first
name; the short name would be andermic. I have all of that working
just fine. My problem is what to do when I have Michelle Anderson,
Michael Anderson and Mickala Anderson all in the same list (real people
in a local school). Mac OS X does not allow duplicate short names and
they would all be andermic. I would like my app to compare the short
name generated and if a duplicate change the last character to a number
1, 2, etc as needed.

I don't know if it is common practice to include sample source code or
a copy of my project when posting questions. So please let me know if
more info is needed.

Any and all help will be greatly appreciated.

Thanks and Have A Great Day.

Rick Davis


---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Re: Checking for string output duplicity...
Date: 01.08.03 10:56 (Fri, 01 Aug 2003 11:56:47 +0200)
From: Frank Bitterlich
Hmmm, maybe I'm the only one, but I don't have a clue what you're actually
asking... :)

I mean, I understand what you want to achieve - write a file with a field
that must contain only unique values. But what is the part you're having
problems with?

The code snippet you posted isn't clear to me either. What is snSel and
snFormat? And what is the meaning of the letter sequences you're comparing
them to?

My basic appraoch to this problem would be to store each written-out
shortname into a dictionary. Before writing the next shortname, check
against the dictionary with .HasKey(). If that returns true, "rotate"
through the last digit/letter of the shortname until .HasKey() returns
false. Repeat and fade...

Maybe if you let us know in a few words which part of the task you're having
problems with, it becomes easier to help you with that.

Cheers,
Frank+++

On 01.08.2003 5:53 Uhr, Rick Davis wrote:

> Heylo again,
...
> I am developing an application that will use a tab-delimited text file
> to generate an XML file that will be used to import users and groups
> into a Mac OS X Server. The user can choose to put the shortName in the
> third field of a tab-delimited text file and then import that shortName
> directly. Or they can choose to generate the shortName using from 0-9
> characters of the first field (first name) and 0-9 characters of the
> second field (last name) of the tab-delimited text file. They also
> have the choice of using the last name then the first name for the
> generated shortName. What I am trying to do is compare the shortName
> as it is being written to my textoutput file (whether imported or
> generated) to the list of shortName's and if the shortName is already
> used then the last character is changed to the number one, if shortNam1
> is already used then the last character should be changed to two,
> shortNam2.
...

---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Re: Checking for string output duplicity...
Date: 01.08.03 16:57 (Fri, 01 Aug 2003 08:57:27 -0700)
From: Richard Davis
Ummmm...I'm sure you're not the only one confused. I myself am clueless...LOL. I could send you the entire project, but then you would probably be more confused. I am very new to programming, a little html and xml for webdesign and that's about it. What I am doing is modifying source code included with a shareware app titled ASIP XML Maker. I have been unable to contact the original developer, so I thought I would give it a try myself. Most of the modifications I have made are working well (the code is probably a mess compared to what a experienced programmer would produce). But I seem to have hit a mental road block on this issue.

Basically the snSel and snFormat fields are the result of radio buttons selected by the user. Depending on which button is selected text is written to a textedit field. The application then uses this information to determine what procedure to use to create the shortName. The resulting shortName is then sent to the textoutputstream. Probably a more elegent way to do this but I am more concerned with this working right now. Once I learn more about programming I will probably cringe when I look back at this project...LOL.

Most people have mentioned using an array to compare the string and change the output as needed. Every attempt I have made at using an array calls for the sring to be an integer and I end up with a type mismatch. I'm sure it's something I am doing incorrectly. It might be time to run through some tutorials.

This is the first time I have heard of .HasKey() and will now take a look at it.

Thanks and Have A Great Day.

Rick Davis

On Fri, 01 Aug 2003. Frank wrote;

Subject: Re: Checking for string output duplicity...
From: "Frank Bitterlich" <<email address removed>>
Date: Fri, 01 Aug 2003 11:56:47 +0200

Hmmm, maybe I'm the only one, but I don't have a clue what you're actually
asking... :)

I mean, I understand what you want to achieve - write a file with a field
that must contain only unique values. But what is the part you're having
problems with?

The code snippet you posted isn't clear to me either. What is snSel and
snFormat? And what is the meaning of the letter sequences you're comparing
them to?

My basic appraoch to this problem would be to store each written-out
shortname into a dictionary. Before writing the next shortname, check
against the dictionary with .HasKey(). If that returns true, "rotate"
through the last digit/letter of the shortname until .HasKey() returns
false. Repeat and fade...

Maybe if you let us know in a few words which part of the task you're having
problems with, it becomes easier to help you with that.

Cheers,
Frank+++

---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Checking for string output duplicity...
Date: 30.07.03 12:37 (Wed, 30 Jul 2003 07:37:36 -0400)
From: Rick Davis
Heylo All,

Very new to RB and programming in general (well, some HTML and XML), so
I may not even ask the question right but will try.

I have written an app that will create an XML file that can then be
imported into Mac OS X Server from a tab-delimited file by importing or
generating the necessary data from two to seven fields. One of the
tasks is to generate a user short name from two fields (first name,
last name) based upon the number of characters assigned by the user.
For instance if the first name is Michelle and the last name is
Anderson; the user asks to generate the short name using the first five
characters of the last name and the first three letters of the first
name; the short name would be andermic. I have all of that working
just fine. My problem is what to do when I have Michelle Anderson,
Michael Anderson and Mickala Anderson all in the same list (real people
in a local school). Mac OS X does not allow duplicate short names and
they would all be andermic. I would like my app to compare the short
name generated and if a duplicate change the last character to a number
1, 2, etc as needed.

I don't know if it is common practice to include sample source code or
a copy of my project when posting questions. So please let me know if
more info is needed.

Any and all help will be greatly appreciated.

Thanks and Have A Great Day.

Rick Davis

---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Re: Checking for string output duplicity...
Date: 30.07.03 15:20 (Wed, 30 Jul 2003 07:20:09 -0700)
From: Joseph J. Strout
At 7:37 AM -0400 7/30/03, Rick Davis wrote:

>My problem is what to do when I have Michelle Anderson, Michael
>Anderson and Mickala Anderson all in the same list (real people in a
>local school). Mac OS X does not allow duplicate short names and
>they would all be andermic. I would like my app to compare the
>short name generated and if a duplicate change the last character to
>a number 1, 2, etc as needed.

Well, you've pretty well described it:

while NameAlreadyUsed(name)
name = Left(name, Len(name) - Len(str(num))) + str(num)
num = num + 1
wend

Cheers,
- Joe