CG shader conditional problem[solved]

Hi, I have been trying to make a custom shader which recognizes if the part being rendered has a texture, if not, it will render that part using vertex colors. For that I´m using a If statement, but how would I write that logic (if texture exists)
I think I should use Sampler2D tex_0 : TEXUNIT0, and somehow turn tex_0 into a value in 0,1 range to check if texture is 0(false) or 1(true), but I do not know how to convert tex_0 that range, if this is really possible, and if tex_o is really what I need.
Any help would be welcome, my code is below, the important part in in the last lines

//Cg
//
//Cg profile arbvp1 arbfp1

void vshader(
uniform float4x4 mat_modelproj,

in float4 vtx_position : POSITION,
in float3 vtx_normal : NORMAL,
in float4 vtx_color : COLOR,
in float2 vtx_texcoord0 : TEXCOORD0,

out float4 l_color : COLOR,
out float2 l_texcoord0 : TEXCOORD0,
out float3 l_myposition : TEXCOORD1,
out float3 l_mynormal : TEXCOORD2,
out float4 l_position : POSITION)

{
l_position = mul( mat_modelproj, vtx_position );
l_texcoord0 = vtx_texcoord0;
l_myposition = vtx_position.xyz;
l_mynormal = normalize( vtx_normal );
l_color = vtx_color;
}


void fshader(
uniform sampler2D tex_0 : TEXUNIT0,
uniform float4 mspos_light,

in float2 l_texcoord0 : TEXCOORD0,
in float3 l_myposition : TEXCOORD1,
in float3 l_mynormal : TEXCOORD2,
in float4 l_color : COLOR,

out float4 o_color : COLOR)

{
float4 finalcolor;
float4 texcolor = tex2D( tex_0, float2( l_texcoord0 ) );
float3 lightpos = mspos_light.xyz;
float3 modelpos = l_myposition;
float3 normal = normalize( l_mynormal );
float3 direction = normalize( lightpos - modelpos );
float toonlight = max( dot( normal, direction ), 0 ) ;
if ( toonlight < 0.5 ) toonlight = 0.8;
else toonlight = 1;
if ( MISSINGCODE ) o_color = texcolor * toonlight;
else o_color = l_color * toonlight;
}

In general you should avoid conditions in shaders if performance is important to you.
If the part of the model in question really has no textures on it, you probably want to just assign a different shader to that part that does not use a texture.
It would be something different if the case was that there actually was texture assigned to that part, but it was black for example.

I see, thanks a lot, teedee!