*** PLEASE HELP *** 
Author Message
 *** PLEASE HELP ***

 Hi All,

I have a problem... when using strings. I have the following string:

1^Tom^Rodman^25th Apt^7th Street^StarkVille^IL^12340^

I want to be able to trim the string in such a mannet that I can set
var to the following sequence:

Record_Num = 1
Fname_Var = Tom
Lname_Var = Rodman
Addrress1_var = 25th Apt
Address2_var = 7th Street
City_var = Starkville
State_var = IL
Zip_var = 123456

and display them into an entry field. Please do help me....
Should I use trim function if so how an example would be great.

Thanking you in advance. Email me the answer.. Thamks.

Regards,



Thu, 16 Mar 2000 03:00:00 GMT  
 *** PLEASE HELP ***

Quote:

> I have a problem... when using strings. I have the following string:

> 1^Tom^Rodman^25th Apt^7th Street^StarkVille^IL^12340^

> I want to be able to trim the string in such a mannet that I can set
> var to the following sequence:

> Record_Num = 1
> Fname_Var = Tom
> Lname_Var = Rodman
> Addrress1_var = 25th Apt
> Address2_var = 7th Street
> City_var = Starkville
> State_var = IL
> Zip_var = 123456

> and display them into an entry field. Please do help me....
> Should I use trim function if so how an example would be great.

No, I wouldn't use trim.  The extended capabilities of foreach
sincetcl7.6 are great for this kind of problem.   Try this:

#!/bin/sh
# next line is a comment in tcl \

set rec {1^Tom^Rodman^25th Apt^7th Street^StarkVille^IL^12340^}

set fields {Record_Num Fname_Var Lname_Var
        Addrress1_var Address2_var City_var State_var Zip_var}

foreach $fields [split $rec ^] {break}

foreach field $fields {puts "$field = [set $field]"}

John Ellson



Thu, 16 Mar 2000 03:00:00 GMT  
 *** PLEASE HELP ***



Quote:
> Hi All,

>I have a problem... when using strings. I have the following string:

>1^Tom^Rodman^25th Apt^7th Street^StarkVille^IL^12340^

>I want to be able to trim the string in such a mannet that I can set
>var to the following sequence:

>Record_Num = 1
>Fname_Var = Tom
>Lname_Var = Rodman
>Addrress1_var = 25th Apt
>Address2_var = 7th Street
>City_var = Starkville
>State_var = IL
>Zip_var = 123456

>and display them into an entry field. Please do help me....
>Should I use trim function if so how an example would be great.

                        .
                        .
                        .
Probably not.  I think you're asking for something on
the order of

        set string {1^Tom^Rodman^25th Apt^7th Street^StarkVille^IL^12340^}
        set list_of_attributes [split $string ^]
        set Record_Num [lindex $list_of_attributes 0]
        set Fname_Var [lindex $list_of_attributes 1]
                ...
        .entry_for_Record_Num insert 0 "$Record_Num"
        .entry_for_Fname_Var insert 0 "$Fname_Var"
                ...
--

Cameron Laird           http://starbase.neosoft.com/~claird/home.html



Thu, 16 Mar 2000 03:00:00 GMT  
 *** PLEASE HELP ***




: >I have a problem... when using strings. I have the following string:
: >1^Tom^Rodman^25th Apt^7th Street^StarkVille^IL^12340^
: >I want to be able to trim the string in such a mannet that I can set
: >var to the following sequence:
: >
: >Record_Num = 1
: >Fname_Var = Tom
: >Lname_Var = Rodman
: >Addrress1_var = 25th Apt
: >Address2_var = 7th Street
: >City_var = Starkville
: >State_var = IL
: >Zip_var = 123456
: >
: >
: >and display them into an entry field. Please do help me....
: >Should I use trim function if so how an example would be great.
:                       .
: Probably not.  I think you're asking for something on
: the order of

:       set string {1^Tom^Rodman^25th Apt^7th Street^StarkVille^IL^12340^}
:       set list_of_attributes [split $string ^]
---- balance of CL's excellent reply omitted ---

Better yet, since you know the fields and the order that they are stored
and displayed, don't worry about fieldnames. Use an array.

set knt 0
foreach itm {split $inline ^} {
incr knt
set inrec($knt) "$itm"

Quote:
}

Now your entire record is stored in an array, you can then do whatever you
want in terms of joining fields, etc. For example:

set fullname "[set rec(2)] [set rec(3)]"

If you control the record format, not using meaningful names and using an
array isn't a real problem. I do recomend that you clearly list the
record format and the expected values at the begining of the code as you
sure as heck won't remember them in six months when you want to modify the
format :-)

jmi



Fri, 17 Mar 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. please, please, please, please, help

2. will someone please, please, please, please HELP me?!!

3. VSE 3.1 Repository Problem: Please help (please please?)

4. PLEASE PLEASE PLEASE HELP !!!!!!!!!!!!

5. help please-----please help about array in DLL

6. Ord Function HELP Please HELP HELP HELP

7. Please Please Help - Clarion External Report Wrtter

8. Please Please help

9. Please Please Help

10. Please, please help!

11. Someone Please Help Me - I Help You in Any Software Queries/Programming/Coding

12. Someone Please Help Me - I Help You in Any Software Queries/Programming/Coding

 

 
Powered by phpBB® Forum Software