Hi,
I'm starting to explore the use of arrays in PB. I'm passing a numeric argument to a subroutine which has a string array. I'd like to look through the array for the string equivalent of that argument and return the full array element. Just don't know how. So in the code example below, if I passed 110 in the sp variable, it would return the string " 110 Spam".
Example:
SUB killem(filepath AS STRING, sp AS BYTE, inputline AS STRING)
DIM res AS STRING
DIM rsns{14)
ARRAY ASSIGN rsns() =" 10 extortion attempt" ," 20 Translator Con" ," 30 had spammy dupe lines." ," 40 Fraud Attempt" ," 50 bogus TLD" ," 60 extortion attempt" ," 70 Spam" ," 80 Hacking" ," 90 Sex Spam" ," 100 Spam "
rsns(10)=" 110 Spam" : rsns(11) =" 120 had IP-based URL." : rsns(12)=" 130 had crap string indicating spammer.": rsns(13)=" 140 Mailgun Spam"
res$=<something using sp and the rsns array>
END SUB
CALL killem(fpath$, 30, emsaved$)
There likely are better ways to do this. Open to suggestions.
Thanks!
--Ben
I'm starting to explore the use of arrays in PB. I'm passing a numeric argument to a subroutine which has a string array. I'd like to look through the array for the string equivalent of that argument and return the full array element. Just don't know how. So in the code example below, if I passed 110 in the sp variable, it would return the string " 110 Spam".
Example:
SUB killem(filepath AS STRING, sp AS BYTE, inputline AS STRING)
DIM res AS STRING
DIM rsns{14)
ARRAY ASSIGN rsns() =" 10 extortion attempt" ," 20 Translator Con" ," 30 had spammy dupe lines." ," 40 Fraud Attempt" ," 50 bogus TLD" ," 60 extortion attempt" ," 70 Spam" ," 80 Hacking" ," 90 Sex Spam" ," 100 Spam "
rsns(10)=" 110 Spam" : rsns(11) =" 120 had IP-based URL." : rsns(12)=" 130 had crap string indicating spammer.": rsns(13)=" 140 Mailgun Spam"
res$=<something using sp and the rsns array>
END SUB
CALL killem(fpath$, 30, emsaved$)
There likely are better ways to do this. Open to suggestions.
Thanks!
--Ben
Comment