Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
vedus
- Livecode Opensource Backer

- Posts: 153
- Joined: Tue Feb 26, 2013 9:23 am
Post
by vedus » Sat Apr 04, 2015 11:18 pm
Maybe is easy but still i can find the how to

.
i have the bellow code
the tNumber get some numbers from 1 to 15
Code: Select all
1:)if tNumber contains "1" then
2:)do something
3:)else if tNumber contains "3" then
4:)do something
5:)else if tNumber "10" then
6: do something
7:end if
the loop restart from line 1 when is on line 3
because "1" and "10" is the same
how can override this behavior ?
Last edited by
vedus on Sun Apr 05, 2015 5:39 pm, edited 1 time in total.
-
SparkOut
- Posts: 2943
- Joined: Sun Sep 23, 2007 4:58 pm
Post
by SparkOut » Sun Apr 05, 2015 12:18 am
I am really not sure what you are trying to do, and how your string of numbers in tNumber looks, but...
try going through the checks in order from more specific to general
Code: Select all
if tNumber is "10" then
doTenThing
else if tNumber contains "1" then
doOneThing
else if tNumber contains "3" then
doThreeThing
end if
Last edited by
SparkOut on Sun Apr 05, 2015 12:20 am, edited 1 time in total.
-
Newbie4
- VIP Livecode Opensource Backer

- Posts: 332
- Joined: Sun Apr 15, 2012 1:17 am
-
Contact:
Post
by Newbie4 » Sun Apr 05, 2015 12:19 am
The simplest way to fix this - is to check for the '10' before you check for the "1"
Code: Select all
if tNumber contains "10" then
do something
else if tNumber contains "3" then
do something
else if tNumber "1" then
do something
end if
Do the same for 11, 12,13,14, and 15
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/
-
vedus
- Livecode Opensource Backer

- Posts: 153
- Joined: Tue Feb 26, 2013 9:23 am
Post
by vedus » Sun Apr 05, 2015 11:26 am
Thank you Sparkout & Newbie4.
I am really not sure what you are trying to do, and how your string of numbers in tNumber looks, but...
The numbers is the first digit from the Hour in 24 format and exist in the fields.
The problem i try to solve is, from 19:00 until 7:00 i need to put the Night images and the rest from 8:00 to 18:00 the Day.
-
Dixie
- Livecode Opensource Backer

- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
Post
by Dixie » Sun Apr 05, 2015 11:54 am
The numbers is the first digit from the Hour in 24 format and exist in the fields.
The problem i try to solve is, from 19:00 until 7:00 i need to put the Night images and the rest from 8:00 to 18:00 the Day.
Code: Select all
on mouseUp
put the seconds into tday
convert tday to dateitems
if item 4 of tday >= 0 and item 4 of tday < 8 then
--go do night time stuff
end if
if item 4 of tday >= 8 AND item 4 of tday <= 18 then
-- go do day time stuff
end if
if item 4 of tday >= 19 AND item 4 of tday <= 23 then
--go do night time stuff
end if
end mouseUp
Last edited by
Dixie on Sun Apr 05, 2015 6:50 pm, edited 1 time in total.
-
vedus
- Livecode Opensource Backer

- Posts: 153
- Joined: Tue Feb 26, 2013 9:23 am
Post
by vedus » Sun Apr 05, 2015 5:39 pm
Dixie wrote:The numbers is the first digit from the Hour in 24 format and exist in the fields.
The problem i try to solve is, from 19:00 until 7:00 i need to put the Night images and the rest from 8:00 to 18:00 the Day.
Code: Select all
on mouseUp
put the seconds into tday
convert tday to dateitems
if item 4 of tay >= 0 and item 4 of tday < 8 then
--go do night time stuff
end if
if item 4 of tday >= 8 AND item 4 of tday <= 18 then
-- go do day time stuff
end if
if item 4 of tday >= 19 AND item 4 of tday <= 23 then
--go do night time stuff
end if
end mouseUp
Thank you Dixie.That solve my problem permanently
