In this example I am getting 3 results each separated separated with "", how could I get each result to be saved as a separate KM variable. The results can vary from 1-5+. I would like to save the result into KM as Address 1, Address 2, Address 3, Address 4 etc..
Here is an example script that show you how to do this.
You will need to adjust the script to fit your needs and variable names.
###AppleScript
## PURPOSE: Convert String to List, and output Each Item in List as KM Variable
--- THIS VARIABLE REPRESENTS YOUR RESULTS ---
-- (change as you like)
set resultsStr to "Some address 1,Some address 2,Some address 3"
--- CONVERT THE STRING INTO A LIST ---
set delimStr to ","
set AppleScript's text item delimiters to delimStr
set resultsList to text items of resultsStr
--- LOOP THROUGH EACH ITEM IN LIST, SET KM VAR ---
set numItems to length of resultsList
repeat with i from 1 to numItems
set kmVarName to "TEST__Address " & i
set addressStr to (item i of resultsList) as text
log (kmVarName & ": " & addressStr)
tell application "Keyboard Maestro Engine" to setvariable kmVarName to addressStr
end repeat