Re: Listing Words Backwords
This WebDNA talk-list message is from 2001
It keeps the original formatting.
numero = 37883
interpreted = N
texte = That's what I was looking for!Sometimes the solution is too easy.Thanks GeneMikeOn Wednesday, August 15, 2001, at 05:38 AM, Gene Beljaeff wrote:> How about this:>> [text]wordlist=a,b,c,d,e[/text]>> [text]_backwardsList=[/text]> [text]_delimiter=,[/text]> [listWords words=[wordlist]&delimiters=[_delimiter]]> [text]_backwardsList=[word][_delimiter][_backwardsList][/text]> [/listWords]>>> [_backwardsList] will contain the initial list, but in reverse order.>> Gene>>>> As the [ListWords] context has no parameters that would allow listing >> in reverse order...>>>> I'm looking for an extremely efficient bit of code that will allow me >> to loop through words in a string in reverse order.>>>> I have created my own solution, but I have a new site that I'll need >> to use this on every page so I am wondering if there might be a more >> streamlined method of doing this, or just something I may have >> overlooked in the docs. My solution uses a combination of two >> listwords loops, several interpret tags, and a numeric loop to do an >> 'artificial array'. I'd like to slim this down if it's at all >> possible.>>>> My solution is an include file that will flip the words in a text >> variable.>> Usage:>> [text]wordlist=a,b,c,d,e[/text]>> [include file=^flipwords.inc&flipwords=wordlist&flipdelimiters=,]>> [wordlist]>>>>>> The output is e,d,c,b,a>>>> Code for flipwords.inc:>>>> ------->> [showif [flipwords]![raw][flipwords][/raw]][!]>> [/!][showif [flipwords]!][!]>> [/!][showif [interpret][[flipwords]][/interpret]!][!]>> [/!][text]flipwordsd=[if >> ([flipdelimiters]![raw][flipdelimiters][/raw])|(>> [flipdelimiters]!)][then][flipdelimiters][/then][else], >> .[/else][/if][/text][!]>> [/!][math show=f]flipwordsx=[countwords >> delimiters=[flipwordsd]][interpret][[flipwords]][/interpret][/countwords]>> [/math]>> [!]>> [/!][math show=f]flipwordsy=[flipwordsx]+1[/math][!]>> [/!][listwords >> words=[interpret][[flipwords]][/interpret]&delimiters=[flipwordsd]][!]>> [/!] [math show=f]flipwordsy=[flipwordsy]-1[/math][!]>> [/!] [text show=t]flipwords[flipwordsy]=[word][delimiter][/text][!]>> [/!][/listwords][!]>> [/!][text][flipwords]=[loop >> start=1&end=[flipwordsx]][interpret][flipwords[index]][/interpret][/loop]>> [/text]>> [!]>> [/!][/showif][!]>> [/!][/showif][!]>> [/!][/showif]>> ------>>>> ------------------------------------------------------------->> This message is sent to you because you are subscribed to>> the mailing list
.>> To unsubscribe, E-mail to: >> To switch to the DIGEST mode, E-mail to > digest@talk.smithmicro.com>>> Web Archive of this list is at: http://search.smithmicro.com/>>> -------------------------------------------------------------> This message is sent to you because you are subscribed to> the mailing list .> To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to digest@talk.smithmicro.com>> Web Archive of this list is at: http://search.smithmicro.com/>-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/
Associated Messages, from the most recent to the oldest:
That's what I was looking for!Sometimes the solution is too easy.Thanks GeneMikeOn Wednesday, August 15, 2001, at 05:38 AM, Gene Beljaeff wrote:> How about this:>> [text]wordlist=a,b,c,d,e[/text]>> [text]_backwardsList=[/text]> [text]_delimiter=,[/text]> [listWords words=[wordlist]&delimiters=[_delimiter]]> [text]_backwardsList=[word][_delimiter][_backwardsList][/text]> [/listWords]>>> [_backwardsList] will contain the initial list, but in reverse order.>> Gene>>>> As the [listwords] context has no parameters that would allow listing >> in reverse order...>>>> I'm looking for an extremely efficient bit of code that will allow me >> to loop through words in a string in reverse order.>>>> I have created my own solution, but I have a new site that I'll need >> to use this on every page so I am wondering if there might be a more >> streamlined method of doing this, or just something I may have >> overlooked in the docs. My solution uses a combination of two >> listwords loops, several interpret tags, and a numeric loop to do an >> 'artificial array'. I'd like to slim this down if it's at all >> possible.>>>> My solution is an include file that will flip the words in a text >> variable.>> Usage:>> [text]wordlist=a,b,c,d,e[/text]>> [include file=^flipwords.inc&flipwords=wordlist&flipdelimiters=,]>> [wordlist]>>>>>> The output is e,d,c,b,a>>>> Code for flipwords.inc:>>>> ------->> [showif [flipwords]![raw][flipwords][/raw]][!]>> [/!][showif [flipwords]!][!]>> [/!][showif [interpret][[flipwords]][/interpret]!][!]>> [/!][text]flipwordsd=[if >> ([flipdelimiters]![raw][flipdelimiters][/raw])|(>> [flipdelimiters]!)][then][flipdelimiters][/then][else], >> .[/else][/if][/text][!]>> [/!][math show=f]flipwordsx=[countwords >> delimiters=[flipwordsd]][interpret][[flipwords]][/interpret][/countwords]>> [/math]>> [!]>> [/!][math show=f]flipwordsy=[flipwordsx]+1[/math][!]>> [/!][listwords >> words=[interpret][[flipwords]][/interpret]&delimiters=[flipwordsd]][!]>> [/!] [math show=f]flipwordsy=[flipwordsy]-1[/math][!]>> [/!] [text show=t]flipwords[flipwordsy]=[word][delimiter][/text][!]>> [/!][/listwords][!]>> [/!][text][flipwords]=[loop >> start=1&end=[flipwordsx]][interpret][flipwords[index]][/interpret][/loop]>> [/text]>> [!]>> [/!][/showif][!]>> [/!][/showif][!]>> [/!][/showif]>> ------>>>> ------------------------------------------------------------->> This message is sent to you because you are subscribed to>> the mailing list .>> To unsubscribe, E-mail to: >> To switch to the DIGEST mode, E-mail to > digest@talk.smithmicro.com>>> Web Archive of this list is at: http://search.smithmicro.com/>>> -------------------------------------------------------------> This message is sent to you because you are subscribed to> the mailing list .> To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to digest@talk.smithmicro.com>> Web Archive of this list is at: http://search.smithmicro.com/>-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/
Michael Davis
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
fresh eyes needed. Append won't work. (2000)
2.0 Info (1997)
Online reference (1997)
Bad Cookie / Internet Option / Internet Explorer (2004)
default value from Lookup (was Grant, please help me) (1997)
form data submission gets truncated (1997)
Tax Moratorium Expiring (2001)
Delayed Redirect (2000)
WebCat2 - [format thousands] (1997)
Obscure Question of the day (1997)
Re:multiple digests, please stop (1997)
Next X hits (1996)
newbie Q: [cart] documentation (1999)
Emailer on NT CAN'T handle large email files (1997)
[WebDNA] [if] or [case] or something else (2012)
[taxrate] question (1997)
Pull Down Search (2000)
[searchString] (1997)
CommandSecurity? (1997)
f2 download problems (1997)