18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Problem with Substring

gbpathergbpather Members
edited November -1 in Sahi - Open Source
Hi,

I am using the following code to read through a string variable but it always returns a null value,
please help

var $temp_value = "Friend";
for (var $i = 0; $i < $temp_value.length; $i++){
if ($temp_value.substring(i, i+1) == "F"){
$c ++;
}
}

Thanks,

Comments

  • hi gbpather

    i think you forgot the dollars on the i_variable:

    var $temp_value = "Friend";
    for (var $i = 0; $i < $temp_value.length; $i++){
    if ($temp_value.substring($i, $i+1) == "F"){
    $c ++;
    }
    }

    this should work.

    regards
    Wormi
  • Hi Wormi,

    Thanks that works, my mistake for missing that out, any idea on the other topic i posted?

    Thanks,
Sign In or Register to comment.