Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » Witz and map variable
Re: Witz and map variable [message #37984 is a reply to message #37981] Tue, 27 November 2012 09:45 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Zbych wrote on Tue, 27 November 2012 08:51

Hi,

I would like to replace some numbers in witz script with string.
Do something similar to Format("%[0:OK;1:ERROR;???]s", error_code).
I guess that map variable should do the trick. Can someone show me example how to create and use map variable in witz?


Hi Zbych,

Using maps in witz is quite straightforward. You just pass it to Skylark in handler:
SKYLARK(MyHandler,"path"){
    int i=1;
    ValueMap map; // ValueArray could be used as well
    map.Add(0,"OK");
    map.Add(1,"ERROR");
    http("ID",i)("MAP",map).RenderResult("MyApp/template");
}

and then you can work with it in the template:
element $ID in MAP is: $MAP[ID]

I haven't tested the code, hopefully I made no mistakes Smile

Best regards,
Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to close a Thread?
Next Topic: What's wrong with this code?
Goto Forum:
  


Current Time: Fri May 10 22:51:04 CEST 2024

Total time taken to generate the page: 0.02988 seconds