1. how test for empty sub-sequence?

How can I test a sequence to see if a sub-sequence is empty or not?

Dan Moyer

new topic     » topic index » view message » categorize

2. Re: how test for empty sub-sequence?

Dan,

Try something like this:

object temp

temp = yourSequence [x] [y] [z]
if sequence (temp) and (length (temp) > 0) then
    .
    .
    .
end if

Joe

-----Original Message-----
From: Euphoria Programming for MS-DOS
[mailto:EUPHORIA at LISTSERV.MUOHIO.EDU]On Behalf Of Dan B Moyer
Sent: Friday, January 28, 2000 11:42 PM
To: EUPHORIA at LISTSERV.MUOHIO.EDU
Subject: how test for empty sub-sequence?


How can I test a sequence to see if a sub-sequence is empty or not?

Dan Moyer

new topic     » goto parent     » topic index » view message » categorize

3. Re: how test for empty sub-sequence?

Joe,

I guess I must have a different problem than I thought, 'cause that didn't
fix it.  Drat. Now I have to think more about what the actual problem might
be. I will save your example in my personal FAQ for future use, though. :)

Dan

-----Original Message-----


>Dan,
>
>Try something like this:
>
>object temp
>
>temp = yourSequence [x] [y] [z]
>if sequence (temp) and (length (temp) > 0) then
>    .
>    .
>    .
>end if
>
>Joe
>
>-----Original Message-----
>From: Euphoria Programming for MS-DOS
>[mailto:EUPHORIA at LISTSERV.MUOHIO.EDU]On Behalf Of Dan B Moyer
>Sent: Friday, January 28, 2000 11:42 PM
>To: EUPHORIA at LISTSERV.MUOHIO.EDU
>Subject: how test for empty sub-sequence?
>
>
>How can I test a sequence to see if a sub-sequence is empty or not?
>
>Dan Moyer

new topic     » goto parent     » topic index » view message » categorize

4. Re: how test for empty sub-sequence?

Dan,
Can you post a little bit of the code that's giving you trouble?
Joe

<snip>

Joe,

I guess I must have a different problem than I thought, 'cause that didn't
fix it.  Drat. Now I have to think more about what the actual problem might
be. I will save your example in my personal FAQ for future use, though. :)

Dan

<snip>

>How can I test a sequence to see if a sub-sequence is empty or not?
>
>Dan Moyer

new topic     » goto parent     » topic index » view message » categorize

5. Re: how test for empty sub-sequence?

Joe,

My code's such a mess at this point I think it would take as long to
abstract relevant snippets as to try to follow what it is I made happen. I
thank you for the offer, & if I start pulling out too much of my hair, I may
re-think & start snipping!

In general, I had made a number of stand-alone modules to make different
tasks work (pretty simple things like: edit keyed in text; save result in
variable to disk; read it; show it with original font size); then I
"integrated" the modules by turning them into includes, with global
variables to pass various info back & forth between them & to "main", and
now it mostly works except in one (?) mostly avoidable instance.  The real
problem is that I'm running the unregistered Euphoria, so while I got error
messages with the small modules, I don't now that I've integrated them, so I
have to THINK about what is happening, & hope I'm mentally following my own
code correctly (no small task for me!).

The problem relates to when I try to set fontsize from info that was stored
into disk file & then read back out into a "structured"(?) variable; it
works ok when I actually DO store font size info, & crashes if I haven't,
that's why I thought I was trying to read an empty sequence.

I'll get back to you if I can't figure it out on my own.  :)

Dan

-----Original Message-----


>Dan,
>Can you post a little bit of the code that's giving you trouble?
>Joe
>
><snip>
>
>Joe,
>
>I guess I must have a different problem than I thought, 'cause that didn't
>fix it.  Drat. Now I have to think more about what the actual problem might
>be. I will save your example in my personal FAQ for future use, though. :)
>
>Dan
>
><snip>
>
>>How can I test a sequence to see if a sub-sequence is empty or not?
>>
>>Dan Moyer

new topic     » goto parent     » topic index » view message » categorize

6. Re: how test for empty sub-sequence?

----- Original Message -----
From: Dan B Moyer <DANMOYER at PRODIGY.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, January 29, 2000 1:09 AM
Subject: Re: how test for empty sub-sequence?



> The problem relates to when I try to set fontsize from info that was
stored
> into disk file & then read back out into a "structured"(?) variable; it
> works ok when I actually DO store font size info, & crashes if I haven't,
> that's why I thought I was trying to read an empty sequence.

Have you considered storing "default" if there is nothing to store, sounds
like what is happening is that nothing is stored, so the data read is
shifted one field up in your structured vars,, and all the records after
that one will be shifted also.

Kat

new topic     » goto parent     » topic index » view message » categorize

7. Re: how test for empty sub-sequence?

Joe,

Well, my problem wasn't an EMPTY sub-sequence, it was a sub-sequence that
had text in it instead of a number.  I had different modules filling the
variable in question at different times, with one filling it with the font
size from an editor, and another earlier module just testing the variables
structure with some dummy text put into it, and my program was bombing when
it read the text and expected a number.

Dan

-----Original Message-----



>Dan,
>Can you post a little bit of the code that's giving you trouble?
>Joe
>
><snip>
>
>Joe,
>
>I guess I must have a different problem than I thought, 'cause that didn't
>fix it.  Drat. Now I have to think more about what the actual problem might
>be. I will save your example in my personal FAQ for future use, though. :)
>
>Dan
>
><snip>
>
>>How can I test a sequence to see if a sub-sequence is empty or not?
>>
>>Dan Moyer

new topic     » goto parent     » topic index » view message » categorize

8. Re: how test for empty sub-sequence?

Kat,

Yeah, that's such a good idea that I actually CAUSED my problem doing ALMOST
that very thing!  What I had done was, I had previously stored "a" default
in it from one routine, but it was a text string, and my later code using it
expected a number there, & bombed when it saw the text & did ok when it got
the actual font size number from a different routine.  What I had sorta
meant all along & forgot, was to put a default FONT SIZE in the variable, &
that would have probably worked just fine all along.  When I finally made
the dang variable print out, it didn't have a number and it wasn't empty
either:  it had my "default" test text in it.  So if I HADN'T put "my"
default in, it probably  would have resulted in the problem you suggested,
but putting "my" default value in (instead of a more valid one) MADE the
problem I experienced, sigh!  Oh well, I THINK I'm learning, maybe.  :)
It's a good thing I don't give up easily.

Dan

-----Original Message-----



>----- Original Message -----
>From: Dan B Moyer <DANMOYER at PRODIGY.NET>
>To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
>Sent: Saturday, January 29, 2000 1:09 AM
>Subject: Re: how test for empty sub-sequence?
>
>
>
>> The problem relates to when I try to set fontsize from info that was
>stored
>> into disk file & then read back out into a "structured"(?) variable; it
>> works ok when I actually DO store font size info, & crashes if I haven't,
>> that's why I thought I was trying to read an empty sequence.
>
>Have you considered storing "default" if there is nothing to store, sounds
>like what is happening is that nothing is stored, so the data read is
>shifted one field up in your structured vars,, and all the records after
>that one will be shifted also.
>
>Kat

new topic     » goto parent     » topic index » view message » categorize

9. Re: how test for empty sub-sequence?

----- Original Message -----
From: Dan B Moyer <DANMOYER at PRODIGY.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, January 29, 2000 7:14 AM
Subject: Re: how test for empty sub-sequence?


> Kat,
>
> Yeah, that's such a good idea that I actually CAUSED my problem doing
ALMOST
> that very thing!  What I had done was, I had previously stored "a" default
> in it from one routine, but it was a text string, and my later code using
it
> expected a number there, & bombed when it saw the text & did ok when it
got
> the actual font size number from a different routine.  What I had sorta
> meant all along & forgot, was to put a default FONT SIZE in the variable,
&
> that would have probably worked just fine all along.  When I finally made
> the dang variable print out, it didn't have a number and it wasn't empty
> either:  it had my "default" test text in it.  So if I HADN'T put "my"
> default in, it probably  would have resulted in the problem you suggested,
> but putting "my" default value in (instead of a more valid one) MADE the
> problem I experienced, sigh!  Oh well, I THINK I'm learning, maybe.  :)
> It's a good thing I don't give up easily.

This kind of thing happens to all of us. Point is, it shouldn't have to
happen!
If we could specify the type of each subsequence, we would be warned as soon
as we tried to assign "Courier" to a subsequence which was previously
defined
to hold an integer or an atom.

e.g:
MyFont = {string Name, integer Size, integer Style}
MyFont[Name] = 12 -- error
MyFont[Size] = "Courier" -- error

Irv

new topic     » goto parent     » topic index » view message » categorize

10. Re: how test for empty sub-sequence?

On Sat, 29 Jan 2000 08:29:12 -0500, Irv Mullins <irv at ELLIJAY.COM> wrote:

>This kind of thing happens to all of us. Point is, it shouldn't have to
>happen!
>If we could specify the type of each subsequence, we would be warned as
soon
>as we tried to assign "Courier" to a subsequence which was previously
>defined
>to hold an integer or an atom.
>
>e.g:
>MyFont = {string Name, integer Size, integer Style}
>MyFont[Name] = 12 -- error
>MyFont[Size] = "Courier" -- error

  Irv

  Why don't you use user define type ?

  Bernie

new topic     » goto parent     » topic index » view message » categorize

11. Re: how test for empty sub-sequence?

----- Original Message -----
From: Bernie Ryan <bwryan at PCOM.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, January 29, 2000 10:30 AM
Subject: Re: how test for empty sub-sequence?


> On Sat, 29 Jan 2000 08:29:12 -0500, Irv Mullins <irv at ELLIJAY.COM> wrote:
>
> >This kind of thing happens to all of us. Point is, it shouldn't have to
> >happen!
> >If we could specify the type of each subsequence, we would be warned as
> soon
> >as we tried to assign "Courier" to a subsequence which was previously
> >defined
> >to hold an integer or an atom.
> >
> >e.g:
> >MyFont = {string Name, integer Size, integer Style}
> >MyFont[Name] = 12 -- error
> >MyFont[Size] = "Courier" -- error
>
>   Irv
>
>   Why don't you use user define type ?

Of course, in this simple example, I could use:
type Font (object f)
    if sequence(f[Name]) and integer(f[Size]) and integer(f[Style]) then
       return 1
    else return 0
end type

Font MyFont
        MyFont = {"Dummy",0,0} -- required initialization

MyFont[Name] = "Courier" -- these are type-checked
MyFont[Name] = 12

The problem is that most of the variables that really need this kind of
checking
often are sequences with 20 - 50 subsequences. Some of the subsequences
contain
subsequences. This makes writing (and maintaining) type definitions more
work than it is worth, especially when you know you are going to turn type
checking off anyway, once the program is debugged, to prevent slowing things
down too much.

I have no objection to writing type definitions for user-defined types, but
it should
only be necessary to "declare" pre-defined types, not type check them
manually,
even when these pre-defined types are incorporated into a larger object or
sequence.

Irv

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu