1. how test for empty sub-sequence?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 28, 2000
- 707 views
- Last edited Jan 29, 2000
How can I test a sequence to see if a sub-sequence is empty or not? Dan Moyer
2. Re: how test for empty sub-sequence?
- Posted by Joe Otto <joeotto at SWBELL.NET> Jan 28, 2000
- 671 views
- Last edited Jan 29, 2000
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
3. Re: how test for empty sub-sequence?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 28, 2000
- 668 views
- Last edited Jan 29, 2000
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
4. Re: how test for empty sub-sequence?
- Posted by Joe Otto <joeotto at SWBELL.NET> Jan 29, 2000
- 679 views
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
5. Re: how test for empty sub-sequence?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 28, 2000
- 674 views
- Last edited Jan 29, 2000
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
6. Re: how test for empty sub-sequence?
- Posted by Kat <gertie at ZEBRA.NET> Jan 29, 2000
- 718 views
----- 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
7. Re: how test for empty sub-sequence?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 29, 2000
- 730 views
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
8. Re: how test for empty sub-sequence?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 29, 2000
- 674 views
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
9. Re: how test for empty sub-sequence?
- Posted by Irv Mullins <irv at ELLIJAY.COM> Jan 29, 2000
- 683 views
----- 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
10. Re: how test for empty sub-sequence?
- Posted by Bernie Ryan <bwryan at PCOM.NET> Jan 29, 2000
- 711 views
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
11. Re: how test for empty sub-sequence?
- Posted by Irv Mullins <irv at ELLIJAY.COM> Jan 29, 2000
- 686 views
----- 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