Solved

call function outside split loop

Posted on 2016-11-24
5
26 Views
Last Modified: 2016-11-29
Hi experts,

I need to get dates from weeknumber and weekday in a split loop, and use a function written by NightWizzard found on CodeProject. It works perfectly outside the loop, but called from within the loop it goes endless, and i have to reopen the browser to stop it.

Any ideas as how to access the function without this happening?

heres the function:

function WeekNrEval(wnr, td)
if wnr <= weeksthisyear then
thisweekstart = DateAdd("d", ((wnr) * 7), FirstWeekMonday)
thisweekdaydate = dateadd("d", td-1, thisweekstart)
WeekNrEval = thisweekdaydate
else

wnr = wnr - weeksthisyear
firstdateofyear = 1 &"/"& 1 &"/"& thisyear+1

firstfourthofyear = DateSerial(thisyear+1, 1, 4)
firstweekmonday = firstfourthofyear - WeekDay(firstfourthofyear, 0) + 1
thisweekstart = DateAdd("d", ((wnr) * 7), FirstWeekMonday)
thisweekdaydate = dateadd("d", td-1, thisweekstart)
WeekNrEval = thisweekdaydate
'response.Write(weeknr & " ugedage: " & weekdayname(weekday(thisweekdaydate)) & " " &  thisweekdaydate & "<br>")
end if

end function

Open in new window


and heres the code with splits and loops:

		weekinterval=Split(XLSweeks, "-")
			if ubound(weekinterval)> 0 then
			for weeknrs = weekinterval(0) to weekinterval(1)

				splitdays=Split(XLSdays, ";")
					for daynr = 0 to ubound(splitdays)
					dayname = splitdays(daynr)
					
							splitlocations=Split(XLSlocations, ";")
							for LocationCt = 0 to ubound(splitlocations)
							building = left(splitlocations(LocationCt), 4)
							localNr = right(splitlocations(LocationCt), 3)								
									
									if dayname = "mandag" then schday = 1
									if dayname = "tirsdag" then schday = 2
									if dayname = "onsdag" then schday = 3
									if dayname = "torsdag" then schday = 4
									if dayname = "fredag" then schday = 5
									if dayname = "lørdag" then schday = 6
									if dayname = "søndag" then schday = 7
										splitct = splitct+1
									
									response.Write(splitct&" "&WeekNrEval(weeknrs, schday)&" "&XLSname&" "&localnr&"<br>")

							next				
					
					next
			next

Open in new window


Hope this i sufficient information

Best regards
Morten B
0
Comment
Question by:MortenWB
  • 3
  • 2
5 Comments
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 41900270
can you provide sample data for :
  • XLSweeks
  • XLSdays
  • XLSlocations
0
 

Author Comment

by:MortenWB
ID: 41900293
hi ryan,

thanks for replying,

yes:
examples could be

XLSweeks: 51-56 (notice that the code are meant to convert the weeknumbers exceeding the last week of the year to continue the next year starting with 1)
XLSdays: mandag;tirsdag
XLSlocations: 1584, 246;1584, 126

(the data are from an excel sheet)
0
 

Accepted Solution

by:
MortenWB earned 0 total points
ID: 41900637
Hi again,

I somehow found the solution, so I'll close the question.

Thanks for your attention.

Best regards
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 41901047
Glad that you found the solution by yourself cheers
0
 

Author Closing Comment

by:MortenWB
ID: 41905459
I do not know what i did wrong when it did not work - typo's maybe, but now everything is up and running.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question