Variables, Versions, loops and some logic!
Hoping that someone is helping me, as this is driving me a bit mad
I am coding in asp, although it is really the logic that I am trying to work so if you can help me in pseudo code or any other language that is also cool.
The overall project is a script which output all possible combinations of a sales message.
So, the sales message could have the following 'variables':
headline
body
callToAction
footer
(for example)
Each of these 'variables' could have several versions (number unknown)
So, we could have:
Variable: headline
versions: headline1,headline2, headline3,headline4
Variable: body
versions: body1, body2, body3
Variable: callToAction
Versions: callToAction1
Variable: footer
Versions: footer1,footer2
Just to be clear, all of the versions are a string.
And also, we don't know in advance how many of each there are going to be.
The data is submitted in a form, with the variables seperate by the string "xvariablex" and the versions within that 'variable' split by the string "xxx2yyy".
So, the full string may be something like:
headline1
xxx2yyy
headline2
xvariablex
form1
xxx2yyy
form2
xvariablex
footer1
xxx2yyy
footer2
xxx2yyy
footer3
xxx2yyy
footer4
In this case, there are 2 headlines, 2 forms and 4 footers.
I am using the following code to find out how many different versions there are of the sales message:
salesmessage=request.form("salesmessage")
variables=split(salesmessage,"xvariablex")
response.write "<p>Number of variables: " & ubound(variables)+1 & "</p>"
m=1
for n=0 to ubound(variables)
versions=split(variables(n),"xxx2yyy")
m=m*(ubound(versions)+1)
versions=""
next
response.write "<p>Number of versions: " & m & "</p>"
In this case, there are 16 possible combinations.
Now, I am creating an array to contain each version of the salesmessage:
dim salesletterversions()
redim salesletterversions(m)
And now I am a bit stuck.
In words, what I want to do, is to run through each variable and then alternate the values amongst the 16 possibles for the header.
And then alternate for the form.
And then do every 4 for the footer.
But a bit unsure how to achieve this.
Please note once again, that in advance I will have no way of knowing how many variables or versions of those variables there will be.
Can anyone help end my misery?!
Thank you.
Steal Amazon, Kindle and Buying Keywords In Seconds!