Nu såg jag att du redan har fått tips på smartare lösning, men det är väl onödigt att bara "slänga" koden när man väl har skrivit den? ;)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(Server.MapPath("config.asp"))
arrText = Split(objTS.ReadAll, vbCrLf)
objTS.Close : Set objTS = Nothing
For i = 0 To UBound(arrText)
If arrText(i) = "[settings]" Then intStart = i + 1
If Left(arrText(i), 1) = "[" AND intStart < (i + 1) Then
intStop = i - 1
Exit For
End If
Next
If intStop <= 0 Then intStop = UBound(arrText)
For i = intStart To intStop
arrTemp = Split(arrText(i), "=")
strAttr = Trim(arrTemp(0))
strVal = Trim(arrTemp(1))
If Trim(Request.Form(strAttr)) <> "" Then strVal = """" & Trim(Request.Form(strAttr)) & """"
strSettings = strSettings & strAttr & " = " & strVal & vbCrLf
Next
For i = 0 To intStart - 1
strSettings = arrText(i) & vbCrLf & strSettings
Next
If intStop < UBound(arrText) Then
For i = intStop + 1 To UBound(arrText)
strSettings = strSettings & arrText(i) & vbCrLf
Next
End If
Set objTS = objFSO.OpenTextFile(Server.MapPath("config.asp"), 2)
objTS.Write(strSettings)
objTS.Close : Set objTS = Nothing
Set objFSO = Nothing
135 ms totalt · 3 externa anrop · v20260731065814-full.b746b907