Use LOOKUP and LOOKDOWN Command instead of IF THEN Statements
Hi EveryOne
I want to learn more about using diffrent commands any
s
I have a project that·I have put on hold for awhile because· of·not know how to do away so many IF THEN Statements
This what i want to do is this
Hours of·Sun Light
···············IF hrs = $10 AND mins = $00 THEN· =· Leave Out side light·ON hours·for·8 hrs and·00 mins
···············IF hrs = $10 AND mins = $30 THEN· =· Leave Out side light·ON hours for·7 hrs·and 30 mins··
···············IF hrs = $11 AND mins = $00 THEN· =· Leave Out side light·ON hours for·7· hrs·and·00 mins
Can some one·give me an example of how to do this with the three above
···············IF hrs = $11 AND mins = $30 THEN· =· Leave Out side light·ON hours·for·6··hrs·and·30 mins
···············IF hrs = $12 AND mins = $00 THEN· =· Leave Out side light·ON hours·for·6· hrs·and·00 mins····
···············IF hrs = $12 AND mins = $30 THEN· =· Leave Out side light·ON hours·for·5· hrs·and·30 mins
·············· IF hrs = $13 AND mins = $00 THEN· =· Leave Out side light·ON hours·for·5· hrs·and·00 mins
·············· IF hrs = $13 AND mins = $30 THEN· =· Leave Out side light·ON hours·for·4· hrs·and·30 mins
·············· IF hrs = $14 AND mins = $00 THEN· =· Leave Out side light·ON hours·for·4· hrs·and·00 mins
·
I would like to learn how to do away with all of the IF THEN Statement
This is what i did was use the Select and case command but can only do the hrs or mins but not both
SELECT hrs
·CASE $10
·GOTO Timer1
·CASE $11
·GOTO Timer2
·CASE $12
·GOTO Timer3
·CASE $13
·GOTO Timer4
·CASE $14
·GOTO Timer5
·ENDSELECT
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/9/2007 3:23:23 AM GMT
I want to learn more about using diffrent commands any

I have a project that·I have put on hold for awhile because· of·not know how to do away so many IF THEN Statements
This what i want to do is this
Hours of·Sun Light
···············IF hrs = $10 AND mins = $00 THEN· =· Leave Out side light·ON hours·for·8 hrs and·00 mins
···············IF hrs = $10 AND mins = $30 THEN· =· Leave Out side light·ON hours for·7 hrs·and 30 mins··
···············IF hrs = $11 AND mins = $00 THEN· =· Leave Out side light·ON hours for·7· hrs·and·00 mins
Can some one·give me an example of how to do this with the three above
···············IF hrs = $11 AND mins = $30 THEN· =· Leave Out side light·ON hours·for·6··hrs·and·30 mins
···············IF hrs = $12 AND mins = $00 THEN· =· Leave Out side light·ON hours·for·6· hrs·and·00 mins····
···············IF hrs = $12 AND mins = $30 THEN· =· Leave Out side light·ON hours·for·5· hrs·and·30 mins
·············· IF hrs = $13 AND mins = $00 THEN· =· Leave Out side light·ON hours·for·5· hrs·and·00 mins
·············· IF hrs = $13 AND mins = $30 THEN· =· Leave Out side light·ON hours·for·4· hrs·and·30 mins
·············· IF hrs = $14 AND mins = $00 THEN· =· Leave Out side light·ON hours·for·4· hrs·and·00 mins
·
I would like to learn how to do away with all of the IF THEN Statement
This is what i did was use the Select and case command but can only do the hrs or mins but not both
SELECT hrs
·CASE $10
·GOTO Timer1
·CASE $11
·GOTO Timer2
·CASE $12
·GOTO Timer3
·CASE $13
·GOTO Timer4
·CASE $14
·GOTO Timer5
·ENDSELECT
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·

·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/9/2007 3:23:23 AM GMT
Comments
DO SELECT mins CASE $30 'Sort by minute value GOSUB half CASE $00 GOSUB oclock ENDSELECT 'Based on selcted subnumber run proper routine ON subnumber GOSUB t800, t730, t700, t630, t600, t530, t500, t430, t400 LOOP half: LOOKDOWN hrs, [noparse][[/noparse]$10, $11, $12, $13], looknum 'minute value of 30 is known, compare hour # and LOOKUP looknum, [noparse][[/noparse]1, 3, 5, 7], subnumber 'assign value to looknum. ie: $11 = 1, or $13 = 3 RETURN 'Based on looknum select subroutine # ie: 3 >> 7 'or 1>>3 oclock: LOOKDOWN hrs, [noparse][[/noparse]$10, $11, $12, $13, $14], looknum LOOKUP looknum, [noparse][[/noparse]0, 2, 4, 6, 8,], subnumber RETURN
I don't mean to brag, but this isn't all that hard to learn,(I did·it tonight)·especially with the help file (check out the example code).· I think this covers all of it.· Feel free to ask questions, but look at the help file first.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
' {$STAMP BS2} ' {$PBASIC 2.5} This_Thread VAR Word My_Question VAR Word Your_Question VAR Word Cool_Thing VAR Word Abandoned VAR Word DO IF This_Thread = My_Question THEN DEBUG "Thank You For Your Time!" ELSEIF This_Thread = Your_Question THEN DEBUG "I Hope This Helps." ELSEIF This_Thread = Cool_Thing DEBUG "AWESOME!!" ELSE DEBUG "What Am I Supposed To Do?" ENDIF DEBUG "D Faust" LOOP UNTIL This_Thread = Abandoned
·
Thank You For your help with this
This an example that i can understand
I did look at the· on line help first·but i did not understand the example that where given
It would be easier if you combined hrs and minutes into one variable.· That said here is what I would do:
DO SELECT mins CASE $30 'Sort by minute value GOSUB half CASE $00 GOSUB oclock ENDSELECT 'Based on selcted subnumber run proper routine ON subnumber GOSUB t800, t730, t700, t630, t600, t530, t500, t430, t400 LOOP half: LOOKDOWN hrs, [noparse][[/noparse]$10, $11, $12, $13], looknum 'minute value of 30 is known, compare hour # and LOOKUP looknum, [noparse][[/noparse]1, 3, 5, 7], subnumber 'assign value to looknum. ie: $11 = 1, or $13 = 3 RETURN 'Based on looknum select subroutine # ie: 3 >> 7 'or 1>>3 oclock: LOOKDOWN hrs, [noparse][[/noparse]$10, $11, $12, $13, $14], looknum LOOKUP looknum, [noparse][[/noparse]0, 2, 4, 6, 8,], subnumber RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/9/2007 1:56:48 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum ON subnum GOTO Hope_this_helps, Thanks!, WOW!! END
Pin U will get
you will get pin ned
infinitys endless journeys 888888888888888888 sideways
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum ON subnum GOTO Hope_this_helps, Thanks!, WOW!! END
Please explane this more for me
I would make the variable in tenths of an hr, so $10 and $30 = $105.
[noparse][[/noparse]How dose this· =·($105) ] = 10 and $30
·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
LOOKDOWN ThisThread, [noparse][[/noparse]Your_?, My_?, Cool_Thing], looknum LOOKUP looknum, [noparse][[/noparse]1, 2, 3], subnum ON subnum GOTO Hope_this_helps, Thanks!, WOW!! END