1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Convert Crystal Report code to Python code [closed]

Discussão em 'Python' iniciado por Stack, Maio 7, 2025.

  1. Stack

    Stack Membro Participativo

    I need to convert this code, which is written in Crystal Report, to Python code so that the result is the same when the input text is inserted.

    Function (StringVar input)
    local stringVar allowedChars:= '!!!#$%&!()*+,-./987651234:;<=>?@ABCDEDGFASD[\]!_!abcdefghijklmnopqrstuvwxyz{|}!';
    local stringVar text:='5@'+input+'$'; //Must return '
    local numberVar i;
    local numberVar sum;
    local numberVar k;
    local stringVar result;
    local stringVar text2;

    for i:=1 to Length(text) step +1 do
    (
    //first occurrence
    local numberVar fO:=instr(text,text);

    //Weighted calculation
    if(fO<i) then sum:= sum + (fO * instr(allowedChars,text))
    else sum:= sum + (i * instr(allowedChars,text));

    //Unweighted calculation
    //sum:= sum + (instr(allowedChars,text));
    );

    if(sum mod Length(allowedChars)=0)
    then result:='0'
    else result:=allowedChars[sum mod Length(allowedChars)];
    (text+result);

    Continue reading...

Compartilhe esta Página