I have an SQR code like this:
begin-procedure SPL-REMOVE($Vndr_Name_Shrt_Usr, :$outputshrt)
Let $valid_chars_shrt = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -.:/'#0123456789#()=+%*"£$'
Let $invalid_chars_shrt = translate($Vndr_Name_Shrt_Usr, $valid_chars_shrt, '')
Let #invalid_shrt = length($invalid_chars_shrt)
If #invalid_shrt
Let $outputshrt = translate($Vndr_Name_Shrt_Usr, $invalid_chars_shrt, '')
Else
Let $outputshrt = $Vndr_Name_Shrt_Usr
End-if
end-procedure
And upon running the SQR, I am getting this error:
(SQR 4008) Unknown function or variable in expression: #0123456789#
Let $valid_chars_shrt = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -.:/'#0123456789#()=+%*"£$'
May I know why is that so? How can I avoid such error from coming up?
If this is truly the code:
Let $valid_chars_shrt = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -.:/'#0123456789#()=+%*"£$'
The problem lies with the single quote before the #012345678. It unbalances the quoted string. Change it to TWO single quotes '' (not a double-quote). That should work but unless I test it, no guarantees.
Related
I have been looking for a solution everywhere on the internet but nowhere I can see a single script which lets me read the name of a variable as a string in Godot 3.1
What I want to do:
Save path names as variables.
Compare the name of the path variable as a string to the value of another string and print the path value.
Eg -
var Apple = "mypath/folder/apple.png"
var myArray = ["Apple", "Pear"]
Function that compares the Variable name as String to the String -
if (myArray[myposition] == **the required function that outputs variable name as String**(Apple) :
print (Apple) #this prints out the path.
Thanks in advance!
I think your approach here might be a little oversimplified for what you're trying to accomplish. It basically seems to work out to if (array[apple]) == apple then apple, which doesn't really solve a programmatic problem. More complexity seems required.
First, you might have a function to return all of your icon names, something like this.
func get_avatar_names():
var avatar_names = []
var folder_path = "res://my/path"
var avatar_dir = Directory.new()
avatar_dir.open(folder_path)
avatar_dir.list_dir_begin(true, true)
while true:
var avatar_file = avatar_dir.get_next()
if avatar_file == "":
break
else:
var avatar_name = avatar_file.trim_suffix(".png")
avatar_names.append(avatar_name)
return avatar_names
Then something like this back in the main function, where you have your list of names you care about at the moment, and for each name, check the list of avatar names, and if you have a match, reconstruct the path and do other work:
var some_names = ["Jim","Apple","Sally"]
var avatar_names = get_avatar_names()
for name in some_names:
if avatar_names.has(name):
var img_path = "res://my/path/" + name + ".png"
# load images, additional work, etc...
That's the approach I would take here, hope this makes sense and helps.
I think the current answer is best for the approach you desire, but the performance is pretty bad with string comparisons.
I would suggest adding an enumeration for efficient comparisons. unfortunately Godot does enums differently then this, it seems like your position is an int so we can define a dictionary like this to search for the index and print it out with the int value.
var fruits = {0:"Apple",1:"Pear"}
func myfunc():
var myposition = 0
if fruits.has(myposition):
print(fruits[myposition])
output: Apple
If your position was string based then an enum could be used with slightly less typing and different considerations.
reference: https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript_basics.html#enums
Can't you just use the str() function to convert any data type to stirng?
var = str(var)
It kinda works, but the problem is that it seems that the MIME_PART structure is not initialized ? all it's properties has the same values, even if I try to open a different mime item.
MIME_PART *pMime;
DHANDLE hPart;
char *pText;
WORD textLen;
if (error = NSFMimePartGetPart(bidLinksItem, &hPart)) {
goto exit;
}
pMime = OSLock(MIME_PART, hPart);
textLen = (pMime->wByteCount) - pMime->wHeadersLen - pMime->wBoundaryLen;
pText = (char *)pMime + sizeof(MIME_PART) + wHeadersLen;
char *itemText = (char *)malloc(textLen);
memcpy(itemText, pText, textLen);
itemText[textLen] = '\0';
OSUnlock(hPart);
The itemText string has most of the content, but since the MIME_PART structure is not properly set, the pointer to the text is off...
So how do I properly set the MIME_PART?
Your code should do something like this instead:
DHANDLE hPart;
char *pchPart;
if (error = NSFMimePartGetPart(bidLinksItem, &hPart)) {
goto exit;
}
pchPart = OSLock(char, hPart);
In other words, lock the handle as type char instead of type MIME_PART. At this point, pchPart points to the beginning of the raw part data -- starting with a boundary (if present) and the headers. You can use NSFMimePartGetInfoByBLOCKID to get the length of the boundary and headers.
I realize this contradicts the documentation, but I've confirmed with a subject matter expert: The documentation is wrong.
Wrong answer, but the comments may be useful. My other answer is more correct.
This question could be improved. For example, you could show some sample data and describe the results when you try to read that data with your code.
But I'll try to answer based on the information I have. You calculated the text length like this:
textLen = (pMime->wByteCount) - pMime->wHeadersLen - pMime->wBoundaryLen;
That looks right to me, but then you do this:
pText = (char *)pMime + sizeof(MIME_PART) + wHeadersLen;
Is wHeadersLen guaranteed to be equal to pMime->wHeadersLen? Also, you didn't consider the boundary length. Shouldn't you calculate the address like this instead?
pText = (char *)pMime + sizeof(MIME_PART) + pMime->wHeadersLen + pMime->wBoundaryLen;
if (vehicleListOnly)
{
results = results.Where(x => x.IsOffer=="True");
}
IsOffer is bit in Database.
Any help is much appreciated. Thanks in advance
IsOffer is a bool true not string "True". You could just do
...
results = results.Where(x => x.IsOffer);
...
Your issue is you are comparing bool values like string, which is causing compiler to raise concern. Hence it is saying "==" can not be applied on operands booean(IsOffer) and string(True). Which is obvious if you compare two data, make sure they are of the same type else you ma end up with issue.
You can use
results = results.Where(x => x.IsOffer == true);
Or
results = results.Where(x => x.IsOffer);
Both will work fine. Hope i was able to explain.
I am having some issue with sql... Below have a working and not working example. I hard coded them so its easier to see.
$deleteData = $con->prepare("DELETE FROM markers WHERE sid=? AND user_id=? AND lat=? AND lng=?");
$deleteData->bind_param("iidd", $sid, $user_id,$lat,$lng);
$sid= '239';
$user_id = '2';
$lat = '39.724869';
$lng = '-91.400116';
$deleteData -> execute();
Some reason when I attempt to delete using type double in bind_param just doesn't work. Any suggestions? I changed it with or without '' around the lat lng, still doesn't work.
If I change it to below, it deletes just fine.
$deleteData = $con->prepare("DELETE FROM markers WHERE sid=? AND user_id=?);
$deleteData->bind_param("ii", $sid, $user_id);
$sid= '239';
$user_id = '2';
$deleteData -> execute();
First of all you have a syntax error in the second example (missing character ").
Also you did not assigned $sid variable.
Then I have a little bit stupid question. Are you aware, that assign of variables $blog_id, $user_id ... etc. must be before call of method $deleteData->bind_param()?
And also, don't forget that when you are comparing 2 real values, then you should also add some tolerance, so try instead:
$deleteData = $con->prepare("DELETE FROM markers WHERE sid=? AND user_id=? AND ABS(lat - ?) < 0.0000001 AND ABS(lng - ?) < 0.0000001");
Replace $blog_id = '239';with $sid = '239'; since that's the variable name you use in the bind_param() statement.
I always have a lot of troubles with variables: float, string and numbers.
Can anyone tell me why this doesn't work?
What did I wrong?
let beforeE = '2.18'
let nrzeros = '000'
let newnr = beforeE * 1.nrzeros
echo newnr
This gives as output 2000 and not 2180.
Why?
I tried to change variables with str2float and tried a few other things
but I receive only errors:
Using float as a string or Variable type mismatch
Tnx in advance.
let beforeE = 2.18 " or str2float('2.18')
let nrzeros = '000'
let newnr = beforeE * str2float(1.nrzeros)
echo newnr