SID-00996: Get substr of a variable $topic in Calc{IF SEARCH
| Status: |
Answered |
TWiki version: |
4.3.1 |
Perl version: |
perl, v5.8.8 |
| Category: |
CategorySearch |
Server OS: |
Red Hat Enterprise Linux Server release 5.1 |
Last update: |
15 years ago |
Hi
When i try something like this
%CALC{"$IF($EXACT(%URLPARAM{"search"}%,),*%RED%XXX.%ENDCOLOR%* , $IF($EXACT(%URLPARAM{"aFormato"}%,Screen), $NOP(%)SEARCH{\"METAXXXX\" scope=\"text\" topic=\"Con$GET(Var)*\" web=\"CMDB\" order=\"topic\" limit=\"all\" nosummary=\"on\" nosearch=\"on\" header=\"|Field|\" format=\"|$SET(base,$SUBSTRING($topic,4,3)) $GET(base) |\"}$NOP(%)) )"}%
The result is "pic" but this is of string "$topic" not the value of the variable $topic.
I know that i need scape the $ but idont know how.
Thanks in advance.
--
DavidLopez - 2010-10-14
Discussion and Answer
Hello. Have you tried
$dollar ?
--
EnriqueCadalso - 2010-10-22
Yes,
i try
$dollar
$dollardollar
and other things like
$SUBSTRING(\$topic, 4, 3)
$SUBSTRING($topic, 4, 3)
$SUBSTRING(%BASETOPIC%, 4, 3)
$SUBSTRING("$topic", 4, 3)
$SUBSTRING(\"$topic\", 4, 3)
$SUBSTRING(\"\$topic\", 4, 3)
$SUBSTRING(\"\$dollartopic\", 4, 3)
--
DavidLopez - 2010-10-25
Well, it is difficult to figure out the code out of context. Try to simplify the code using INCLUDES to SECTIONS in the same page instead of nested IFs, so you dont have to scape so many things. Here some examples from a working application for you to see what can be done this way.
You can also use
GluePlugin to format the code as shown in the last example below.
%SEARCH{ ... format="%INCLUDE{"%BASETOPIC%" section="SECTION_ONE" }%" }%
%STOPINCLUDE% <this is because all this topic is included later to skip the rest)
%STARTSECTION{"SECTION_ONE"}%
More simple code. Here a working example from real application
<form name='makeChange$topic' action='%SCRIPTURL{save}%/%BASEWEB%/$topic' method='POST'>
<input name='redirectto' type='hidden' value='%SCRIPTURL{view}%/%BASEWEB%/TrackigList#report$topic' >
<textarea name='comentado' id='comentado' style='visibility: hidden;'>
$formfield(Comentarios)
...
<td width='20%' colspan='3' rowspan='1' class='%CALC{ $IF( $formfield(Estado)==1, seguimientocell, seguimientocellinverse ) }%'>
...
<tr>
<td class='seguimientoheader'>Creado</td>
<td class='seguimientocell'>%REVINFO{ "$date" topic="$topic" rev="1.1" }%</td>
<td class='seguimientoheader'>Actualizado</td>
<td class='seguimientocell'>Semana %CALC{ $TIME( $formfield(FechaActualizacion) ) }%</td>
<td colspan='1' class='seguimientoheader'>Duracion</td>
<td class='seguimientocell'>%CALC{ $ROUND( $TIMEDIFF( $TIME( %REVINFO{ "$date" topic="$topic" rev="1.1"}% ), $TIME(%DISPLAYTIME%), week ), -1) }% Semanas</td>
</tr>
<tr>
...
%STARTSECTION{"MuestraEstado"}% <td class='%CALC{ $IF( ($formfield(Estado)>=%ESTADO%), estadovencido, estadopendiente ) }%'>
~~~ %TOOLTIP{
~~~ TITLE=\"Estado\"
~~~ TEXT=\" %CALC{$LISTITEM(%ESTADO%, %ESTADOS% )}%\"
~~~ WIDTH=\"200\"
~~~ ABOVE=\"true\"
~~~ BORDERCOLOR=\"#3e3f82\"
~~~ BGCOLOR=\"#fffffa\"
~~~ }%%CALC{$LISTITEM(%ESTADO%, %ESTADOSABREV% )}%%TOOLTIP{END}%:
~~~ %CALC{ $IF( $formfield(Estado) == %ESTADO%,
~~~ $INT( $TIMEDIFF( $TIME( %FECHAEST% ), $TIME(), week )),
~~~ $IF( $formfield(Estado) > %ESTADO%,
~~~ $INT( $TIMEDIFF( $TIME( %FECHAEST% ), $TIME( %FECHASIG% ), week )),
~~~ 0 ))}%
~~~ </td>%ENDSECTION{"MuestraEstado"}%
%ENDSECTION{"SECTION_ONE"}%
--
EnriqueCadalso - 2010-10-25
Oki,
Nice idea. But dont work whith my needs.
Finally I delete de CALC and only make the search, and I replace the IF with javascript functions and hidden fields.
Thanks.
--
DavidLopez - 2010-10-25
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
PeterThoeny - 2011-01-04
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.