oleppedersen
New Member
- Joined
- Mar 23, 2013
- Messages
- 13
Hi, I have searched for this to no avail, any help greatly appreciated:
I run through several huge datasets in order to analyze some KPI's. The output is natural langage text.
In the text variable that contains the full analysis, placeholder text e.g. 'xxSNITTxx'<snitt<'<name>, <total> etc are placed. Before writing the analysis to the database, these placeholder texts (there can be MANY in one final text) are replaced with the correct values based on the same number of variables as there are placeholder variations.
The problem is, this leads to a VERY long code where I look for ALL placeholders separately:
With possibly 50 placeholders, this will be 400 lines of code by itself. In this example, xxSNITTxx <snitt>is replaced by the value contained by the variable snitt. This works great.
I am still thinking: There must be a way to keep all placeholders info in an array? However, how do I handle the VARIABLE that the placeholder is replaced with? (In the example, 'snitt')
When I try this, the valVar is just replaced by the variable NAME, not the value of the variable.
Just to be clear: I definitely need the placeholder text system. Natural text is written by analyst outside the code, and the writer only concerns her-/himself with adding the placeholders. This is great, and more important to keep, than to solve my little, but annoying problem.</snitt></snitt<<snitt></total></snitt<'<name>
I run through several huge datasets in order to analyze some KPI's. The output is natural langage text.
In the text variable that contains the full analysis, placeholder text e.g. 'xxSNITTxx'<snitt<'<name>, <total> etc are placed. Before writing the analysis to the database, these placeholder texts (there can be MANY in one final text) are replaced with the correct values based on the same number of variables as there are placeholder variations.
The problem is, this leads to a VERY long code where I look for ALL placeholders separately:
Code:
ant = InStr(aD(i, 3), "xxSNITTxx<snitt<<snitt>")
If ant > 0 Then
aD(i, 3) = Left(aD(i, 3), ant - 1) & snitt & " " & Right(aD(i, 3), Len(aD(i, 3)) - ant - 9)
If ant > 1 Then
GoTo erstattkode
Else: ant = 0
End If
End If
I am still thinking: There must be a way to keep all placeholders info in an array? However, how do I handle the VARIABLE that the placeholder is replaced with? (In the example, 'snitt')
Code:
for x = 1 to 50
txtExp = aPlaceholder(x,1)
valVar = aplaceholder(x,2)
valLength = aPlaceholder(x,3)
repeatcode: ' in case there are several instances of the same variable in the same text
ant = InStr(aD(i, 3), txtExp) ' this is ok
If ant > 0 Then
aD(i, 3) = Left(aD(i, 3), ant - 1) & valVar & " " & Right(aD(i, 3), Len(aD(i, 3)) - ant - valLength) ' I can't get this to work
If ant > 1 Then
GoTo repeatcode
Else: ant = 0
End If
End If
next x
When I try this, the valVar is just replaced by the variable NAME, not the value of the variable.
Just to be clear: I definitely need the placeholder text system. Natural text is written by analyst outside the code, and the writer only concerns her-/himself with adding the placeholders. This is great, and more important to keep, than to solve my little, but annoying problem.</snitt></snitt<<snitt></total></snitt<'<name>
Last edited: