Soubor sem přiložit přímo nemůžu tak popíšu a vložím pouze VBA kód.
V Excelu vytvořit tři listy:
1) code - a sem nakopírovat váš zdrojový kód v SDS-C
2) code_prepare - sem se ukládají výsledky a mám tady spouštěcí tlačítka pro makra
3) get - sem do buněk A1:A9 vložte řetězce ve tvaru http://192.168.2.250/get_ram[0]?rn=100&rand=Math.random(), ve kterých postupně měnte index vždy po 100 až do 400, potom stejné pro get_sys[0],....sys[300], zde je možnost to dále rozšířit a použít i get_txt ale je potom nutno v kódech uprait offsety řádků
Potom do modulu zkopírujte VBA kód přiloženy na konci.
Z něj pak přímo volám dve funkce:
1) nacti_var() - ta projde SDC program uložený na listu CODE a vytáhne z něj proměnné z řádků ve tvaru
"#define SERIAL_OUT ram[109] // příznak že se ma zahájit odeslání"
nebo pole z řádků typu
"//## ram [300-319] nefiltrované teploty"
na list code_prepare
2) aktualizuj() - která potom pomocí dvou funkcí načte a rozparsuje hodnoty z SDC na listu GET a následně je přiřadí k proměnným na listu code_prepare
Vlastní VBA kód:
Sub nacti_var()
rd = 0
For r = 1 To Sheets("code").Rows.Count
txt = Sheets("CODE").Cells(r, 1).Value
txt = Trim(txt)
If txt <> "" Then
If Left(txt, 7) = "#define" Then
rd = rd + 1
rest_txt = Trim(Mid(txt, 8))
x = InStr(rest_txt, " ")
val_name = Mid(rest_txt, 1, x - 1)
x = InStr(rest_txt, " ")
rest_txt = Trim(Mid(rest_txt, x + 1))
val_type = Left(rest_txt, 3)
rest_txt = Mid(rest_txt, 4)
x = InStr(rest_txt, "]")
val_poz = Replace(Left(rest_txt, x), "[", "")
val_poz = Replace(val_poz, "]", "")
val_comm = Trim(Mid(rest_txt, x + 1))
Sheets("CODE_prepare").Cells(rd, 1).Value = val_name
Sheets("CODE_prepare").Cells(rd, 2).Value = val_type
Sheets("CODE_prepare").Cells(rd, 3).Value = val_poz
Sheets("CODE_prepare").Cells(rd, 4).Value = val_comm
End If
If Left(txt, 4) = "//##" Then
rd = rd + 1
rest_txt = Trim(Mid(txt, 5))
val_name = Mid(rest_txt, 1, InStr(rest_txt, "]"))
val_type = Left(rest_txt, 3)
rest_txt = Mid(rest_txt, 4)
x = InStr(rest_txt, "]")
val_poz = Left(rest_txt, x)
val_comm = Trim(Mid(rest_txt, x + 1))
Sheets("CODE_prepare").Cells(rd, 1).Value = val_name
Sheets("CODE_prepare").Cells(rd, 2).Value = val_type
Sheets("CODE_prepare").Cells(rd, 3).Value = val_poz
Sheets("CODE_prepare").Cells(rd, 4).Value = val_comm
End If
End If
Next r
End Sub
Sub prirad_get()
r = 1
Do While Len(Sheets("code_prepare").Cells(r, 2).Value) > 1
idx = Trim(Sheets("code_prepare").Cells(r, 3).Value)
typ = Sheets("code_prepare").Cells(r, 2).Value
If IsNumeric(idx) Then
sloupec = Int(idx / 100)
If typ = "sys" Then sloupec = sloupec + 5
radek = idx - 100 * Int(idx / 100) + 10
Sheets("code_prepare").Cells(r, 6).Value = Sheets("get").Cells(radek, sloupec + 1)
Else
If Left(idx, 1) = "[" Then
idx = Mid(idx, 2)
x = InStr(idx, "-")
prvni = Left(idx, x - 1)
idx = Mid(idx, x + 1)
posledni = Left(idx, Len(idx) - 1)
pole = ""
For i = prvni To posledni
sloupec = Int(i / 100)
If typ = "sys" Then sloupec = sloupec + 5
radek = i - 100 * Int(i / 100) + 10
pole = pole & Sheets("get").Cells(radek, sloupec + 1) & "|"
Next i
Sheets("code_prepare").Cells(r, 6).Value = pole
End If
End If
r = r + 1
Loop
End Sub
Sub nacti_get()
For j = 1 To 9
Sheets("get").Cells(j, 2).Value = http_get(Sheets("get").Cells(j, 1).Value)
Next j
For j = 1 To 9
rd = 10
txt = Sheets("get").Cells(j, 2).Value
Do While (Len(txt) > 0)
x = InStr(txt, "|")
If x > 0 Then
Sheets("get").Cells(rd, j).Value = Left(txt, x - 1)
Else
Sheets("get").Cells(rd, j).Value = txt
Exit Do
End If
txt = Mid(txt, x + 1)
rd = rd + 1
Loop
Next j
End Sub
Sub aktualizuj()
Call nacti_get
Call prirad_get
End Sub