2016-08-11 2 views
0

에 의해 배열의 요소를 가져옵니다이 코드를 가지고 :프리 마커 : 인덱스

<#local slots = time_utils.get_slots(objectArray) /> 
<#local days = time_utils.get_short_days(objectArray) /> 
<#local index = 0 /> 
<#list days as day> 
    <#list slots as slot> 
     <#if time_utils.is_slot_available(objectArray[index], slot, day)> bla bla </#if> 
     <#local index = index + 1 /> 
    </#list> 
</#list> 

기능 :

<#function is_slot_available date slot short_date> 
    <#local hour_of_date = '${date.startsAt?string["HH"]}' />  
    <#local day_of_date = '${date.startsAt?string["dd"]}' /> 
    <#if (hour_of_date == '${slot[6..7]}') && (day_of_date == '${short_date[short_date?length-5..short_date?length-4]}')> 
     <#return true />  
    </#if> 
    <#return false /> 
</#function> 

이 코드를 실행하면, 나는 오류가 있습니다 오류 실행 매크로를 : is_slot_available 필수 매개 변수 : 날짜가 지정되지 않았습니다.

index을 0으로 바꾸거나이 함수 호출에서 objectArray[index]의 숫자로 바꾸면이 오류가 발생하지 않습니다.

그럼 어떻게 할 수 있습니까?

감사합니다. @ddekany에

+0

함수를 호출 할 때'day'를'slot'과'slot'을'short_date'로 넘깁니다. –

+0

아니요. 감사! – dardy

+1

'index' 값이 범위를 벗어날 때까지 증가하거나'null'을 저장하는 배열 항목으로 실행된다고 생각합니다. (문제는 아니지만 가능합니다 :'<#local index ++ />') – ddekany

답변

0

감사 : 문제가 있었다

I guess the value of index increases until it goes out of range, or runs into an array item that stores null.


.

관련 문제