1. Help with seq's
Hi
I need some help with this
include get.e
with trace
sequence lname--,fname
object count,t1,count2,k,string1,string2,string3--,count3
-- 1 1 1 2
lname={{".Tesing 1 1","testing 1 2"},
-- 2 1 2 2
{"testing 2 1","Tesing 2 2"},
-- 3 1 3 2
{"Testing 3 1","Testing 3 2"},
-- 4 1 4 2
{"test 4 1","test 4 2"}}
for q= 1 to length(lname) do
puts(1,lname[q][1])
puts(1,"\n")
puts(1,lname[q][2])
puts(1,"\n")
end for
count2=prompt_number("Enter 1 array # > ",{})
count= prompt_number("Enter 2 array # > ",{})
puts(1,"\n")
t1=length(lname)
print(1,t1)
puts(1,"\n")
puts(1,lname[count2][count])
k=wait_key()
clear_screen()
-- Test to make a seq This is the Part that I need help with
trace(1)
string3=""
string1=prompt_string("Enter a string > ")
string1="{"&string1&"}"
string2=prompt_string("Enter a String 2 > ")
string2="{"&string2&"}"
string3=string1&string2
--count3=prompt_number("enter a Number > ",{})
puts(1,string3[1])
I am trying to put together and array of seq's then I could access them
with string3[1] or 2 but when I try this it does not work I get d and not
David or what I put in there.Thanks for the help
David
pmosley at infoway.lib.nm.us
2. Re: Help with seq's
David,
Hopefully this example will clear things up a bit for you:
include get.e
sequence lname--,fname
sequence string1,string2,string3--,count3
integer index1, index2
lname = {
-- [1][1] [1][2]
{"Testing 1 1","Testing 1 2"},
-- [2][1] [2][2]
{"Testing 2 1","Testing 2 2"},
-- [3][1] [3][2]
{"Testing 3 1","Testing 3 2"},
-- [4][1] [4][2]
{"Testing 4 1","Testing 4 2"}}
clear_screen()
for q = 1 to length(lname) do
puts(1,lname[q][1]&"\n")
puts(1,lname[q][2]&"\n")
end for
puts( 1, "\n" )
index1 = prompt_number("Enter index 1 # > ",{1,length(lname)})
index2 = prompt_number("Enter index 2 # > ",{1,2})
puts( 1, "\n" )
puts( 1, lname[index1][index2]&"\n" )
printf( 1, "there are %d elements in sequence 'lname'\n\n", length(lname) )
--clear_screen()
-- Test to make a seq This is the Part that I need help with
string1 = prompt_string( "Enter a string > " )
string2 = prompt_string( "Enter another string > " )
string3 = {string1,string2}
--count3=prompt_number("enter a Number > ",{})
puts( 1, string3[1]&"\n" )
puts( 1, string3[2]&"\n\n" )
-- add string3 to lname
lname = append( lname, string3 )
-- display lname
for q = 1 to length(lname) do
puts(1,lname[q][1]&"\n")
puts(1,lname[q][2]&"\n")
end for
-- Brian
3. Re: Help with seq's
At 10:50 AM 9/28/00 -0700, you wrote:
>David,
>
>Hopefully this example will clear things up a bit for you:
>
>-- Test to make a seq This is the Part that I need help with
>string1 = prompt_string( "Enter a string > " )
>string2 = prompt_string( "Enter another string > " )
>string3 = {string1,string2}
>-- Brian
>
Hi Brian and fritz
Thanks for the help so when you put 2 seq's together you need to put
{string1,string2} it works in the program I am working on a program that
will help people get to know all about seq's hopefully by the way I could
not find that in the ref.man or lib.doc agian thanks for the help.
David
pmosley at infoway.lib.nm.us
4. Re: Help with seq's
On Thu, 28 Sep 2000 15:49:22 -0400, David Mosley wrote:
>At 10:50 AM 9/28/00 -0700, you wrote:
>>David,
>>
>>Hopefully this example will clear things up a bit for you:
>>
>
>
>>-- Test to make a seq This is the Part that I need help with
>>string1 = prompt_string( "Enter a string > " )
>>string2 = prompt_string( "Enter another string > " )
>>string3 = {string1,string2}
>
>>-- Brian
>>
>Hi Brian and fritz
>Thanks for the help so when you put 2 seq's together you need to put
>{string1,string2} it works in the program I am working on a program that
>will help people get to know all about seq's hopefully by the way I could
>not find that in the ref.man or lib.doc agian thanks for the help.
>
>David
>pmosley at infoway.lib.nm.us
actually, when I think of putting 2 sequences together, I
think 'concatenating 2 sequences' which means putting them together into
one sequence. For example:
----------
sequence string1, string2, string3
string1 = "string1"
string2 = "string2"
string3 = string1 & string2
----------
in the program above, we concatenated string1 and string2 so
string3 = "string1string2"
I'd call what we did in your program 'creating a sequence of 2 sequences'.
----------
sequence string1, string2, string3
string1 = "string1"
string2 = "string2"
string3 = {string1,string2}
----------
in the program above, we created a sequence of strings (which are sequences
of ASCII codes).
string3 = { "string1", "string2" }
= {{115,116,114,105,110,103,49},{115,116,114,105,110,103,50}}
there are other ways to do the same thing (making sequences of
strings/sequences)
For example:
----------
sequence string1, string2, string3
string1 = "string1"
string2 = "string2"
string3 = {string1}&{string2}
----------
or
----------
string3 = append({string1},string2)
----------
or
----------
string3 = prepend({string2},string1)
----------
will all give the same results:
string3 = { "string1", "string2" }
= {{115,116,114,105,110,103,49},{115,116,114,105,110,103,50}}
but be careful not to do this:
string3 = append(string1,string2)
because you'll get this:
instead of this:
Sometimes I still make mistakes like the last example and it just takes the
reference manual and a little trial & error to get the structure I'm
looking for.
-- Brian