Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Is string a valid .......?

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
07-30-2009 14:36
So i'm scripting up an object that uses a notecard to configure some variables for the script.
some vectors, floats, and integers are being used.

i used the example on this page to check if the data is a valid vector

http://www.lslwiki.net/lslwiki/wakka.php?wakka=vector

however, i tried to use the second part of that example to check if a string is a valid decimal.
the problem is, it still returns true when fed an empty string ("";). i could i guess check if the string is empty before performing that test, but i was hoping not to

also, it's using some textures for some variables. currently i'm checking if the texture is in the contents of the prim. but to save on content loading, it can also use the uuid to apply the texture instead. however, there's no way to check if it's a valid texture uuid if the "named" texture isn't present. if it's a valid uuid, but not a texture, it just applies a gray goo texture, but if it's not a valid uuid, and the texture isn't present, it throws a script error

i thought about trying to apply the texture and then using llGetTexture to see if it returns NULL_KEY, but when fed a valid non-texture uuid, it applys it as a gray goo as said before, and llGetTexture still returns the uuid it was fed


i tried it with

CODE

default
{
state_entry()
{
key owner = llGetOwner();
llOwnerSay(owner);
llSetTexture(owner,0);
llOwnerSay(llGetTexture(0));
}

touch_start(integer total_number)
{
llDie();
}
}
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
07-30-2009 14:58
ok, i figured out i just needed to add a line to the test for it to return false for an empty string

CODE

//returns TRUE if the string is a decimal
integer strIsDecimal(string str)
{
str = llStringTrim(str, STRING_TRIM);

integer strLen = llStringLength(str);
if(!strLen){return FALSE;}//ADDED THIS LINE

integer i;
...........................rest of code
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369