Strange behaviour using the "convert" command

Kay C Lan lan.kc.macmail at gmail.com
Tue Jan 1 09:00:56 EST 2013


I'm not exactly sure but having 'break' statements inside IF THEN END IF
seems wrong to me. When you get to the 'break' statement the code
immediately jumps to the 'end switch' statement, completely bypassing the
'end if'. I would think the engine is then still looking for the 'end if'
and not finding it.

What happens if you re-write your switch statement to:

case (tArrayElement[1] = "ListDateField")
    put field "ListDateField" into tEnteredDate
    convert tEnteredDate to seconds
    put tEnteredDate into tValue
    break
case (tArrayelement[1] = "ListingExpiryDateField")
    put field "ListingExpiryDateField" into tEnteredDate
    convert tEnteredDate to seconds
    put tEnteredDate into tValue
    break
case (tArrayElement[1] = "OpenHourDateField")
    put field "OpenHourDateField" into tEnteredDate
    convert tEnteredDate from short date to seconds
    put tEnteredDate into tValue
    break
case (… )
    ...
    break
end switch

HTH

On Tue, Jan 1, 2013 at 7:15 PM, Nigel Soden <nigels at amglighthouse.co.za>wrote:

> Greeting to all in this the 1st of Jan 2013
>
> And yes I'm working.
>
> I have an array that is being looped though in which to build a SQL string
> that'll contain data that will be used in a SQL INSERT.
>
> The loop works great until I get to use the "convert" command.  I have to
> convert the date into seconds as this is what is been used in the main
> database sitting somewhere else as this application is to be used on an
> iPad using SQLITE.  I have various option in which to convert the date to
> seconds. The one I choice for this is when building the string up that'll
> contain the data is at the point when building this string.
>
> The problem is as follows. The first time the code block containing a date
> it converts the date into seconds successfully. The very next iteration of
> the loop is also a date and that portion of the code just does "nothing".
> No conversion occurs, the very next iteration of  the loop is also a date
> format and that too does not work neither.
>
> The code for the conversion is as follows.
>
>
> case "DateEntryField"
>
>             put empty into tEnteredDate
>
>             if tArrayElement[1] = "ListDateField" then
>                put field "ListDateField" into tEnteredDate
>                convert tEnteredDate to seconds
>                put tEnteredDate into tValue
>                break
>             end if
>
>             if tArrayelement[1] = "ListingExpiryDateField" then
>                put field "ListingExpiryDateField" into tEnteredDate
>                convert tEnteredDate to seconds
>                put tEnteredDate into tValue
>                break
>             end if
>
>             if tArrayElement[1] = "OpenHourDateField" then
>                put field "OpenHourDateField" into tEnteredDate
>                convert tEnteredDate from short date to seconds
>                put tEnteredDate into tValue
>                break
>             end if
>
>
> as you will notice the only difference to the three blocks of code is the
> field name were the date is being held. For the rest of the block it is
> identical.
> I've tried the different syntax's but to no avail.
>
> Any suggestions.
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list