Is this an unexpected keyword - coldfusion

I'm inside of a ColdFusion custom tag, and this line
20 : param attributes.name = "";
21 : param attributes.id = attributes.name;
22 : param attributes.inline false;
23 : param attributes.look = "";
24 : param attributes.processed = true;
Update
This is OK
22 : if(!structKeyExists(attributes, "inline")) attributes["inline"] = false;
Gets an error
You cannot use a variable reference with "." operators in this context
The CFML compiler was processing:
A script statement beginning with param on line 22, column 9.
A script statement beginning with { on line 12, column 36.
A script statement beginning with switch on line 12, column 1.
A cfscript tag beginning on line 6, column 2.
Is this a keyword? If so what is it?

You have missed equal to (=) operator on line 22.
Instead of
param attributes.inline false;
Write
param attributes.inline = false;

Related

Flutter - Dart - remove hidden character from String input

I'm trying to compare 2 strings, however my comparison always fails.
For reference, the one string is a filename I'm getting from the phones storage and it look like it ends with an apostrophe, although its not visible anywhere.
Please consider the following dart code:
import 'dart:convert';
void main() {
const Utf8Codec utf8 = Utf8Codec();
String input = 'chatnum.txt';
String stringwithapostrophe = 'chatnum.txt\'';
String compInput = utf8.encode(input).toString();
String compComp = utf8.encode(stringwithapostrophe).toString();
print (compInput);
print (compComp);
if (compInput == compComp) {
print ('Yes it matches');
} else {
print ('No it does not');
}
}
This output's a result of:
[99, 104, 97, 116, 110, 117, 109, 46, 116, 120, 116]
[99, 104, 97, 116, 110, 117, 109, 46, 116, 120, 116, 39]
No it does not
So how can I remove that last apostrophe from the String?
I've tried .removeAt and .removeLast. But I just can't crack this.
I applied regex to it. That sorted it:
String filenametosend = (basename(f.toString()))
.replaceAll(RegExp(r"[-!$%^&*()+|~=`{}##\[\]:;'’<>?,\/"
'"”'
"]"), '');
This way too:
final apostrophe = '\'';
final length = stringwithapostrophe.length;
if (length > 0 && stringwithapostrophe[length - 1] == apostrophe) {
stringwithapostrophe = stringwithapostrophe.substring(0, length - 1);
}
Or this way (remove all):
final apostrophe = '\'';
stringwithapostrophe = stringwithapostrophe.replaceAll(apostrophe, '');
Remove (any) last:
final length = stringwithapostrophe.length;
stringwithapostrophe = length > 0
? stringwithapostrophe.substring(0, length - 1)
: stringwithapostrophe;

C++, comparing string in lines

I need to check if my variable exist in specific place in each line in text file and if its same as in line.
lines in my text example:
one two variable 11 221
123 t12 variable 11 331
123 t12 bad_var 11 331
i want to check if the variable exist in line at place from 9 to 16 in line.
My code:
std::ifstream my_text_file("text_file.txt");
std::string str
if(my_text_file)
{
while(std::getline(my_text_file,str))
{
if(my_text_file.seekg(9,std::ios::beg))
{ //what should i wrote here?// }
}
}
EDIT:
My variable its string looking like abc3 , how can i choose only first 3 letters to compare from my variable like abc ?
Thanks
It would probably be easiest to read the entire line into a string and then check for variable at the correct position within the string using substr().
std::getline(my_text_file, str);
std::string var = "variable";
if (str.substr(9, var.size()) == var) {
// do stuff
}

How to set a variable inside `if` in Sass?

Is it possibel to set a variable inside the parentheses of an if statement in Sass?
I've tried to:
#function test() {
#if ($variable: true) { <<<< line 67
#return $variable;
}
}
And it says: Undefined variable: "$variable". on line 67 at column 8.
I've tried also to place = instead :, but the result is the same.

Error in writing output file through AWK scripting

I have a AWK script to write specific values matching with specific pattern to a .csv file.
The code is as follows:
BEGIN{print "Query Start,Query End, Target Start, Target End,Score, E,P,GC"}
/^\>g/ { Query=$0 }
/Query =/{
split($0,a," ")
query_start=a[3]
query_end=a[5]
query_end=gsub(/,/,"",query_end)
target_start=a[8]
target_end=a[10]
}
/Score =/{
split($0,a," ")
score=a[3]
score=gsub(/,/,"",score)
e=a[6]
e=gsub(/,/,"",e)
p=a[9]
p=gsub(/,/,"",p)
gc=a[12]
printf("%s,%s,%s,%s,%s,%s,%s,%s\n",query_start, query_end,target_start,target_end,score,e,p,gc)
}
The input file is as follows:
>gi|ABCDEF|
Plus strand results:
Query = 100 - 231, Target = 100 - 172
Score = 20.92, E = 0.01984, P = 4.309e-08, GC = 51
But I received the output in a .csv file as provided below:
100 0 100 172 0 0 0 51
The program failed to copy the values of:
Query end
Score
E
P
(Note: all the failed values are present before comma (,))
Any help to obtain the right output will be great.
Best regards,
Amit
As #Jidder mentioned, you don't need to call split() and as #jaypal mentioned you're using gsub() incorrectly, but also you don't need to call gsub() at all if you just include , in your FS.
Try this:
BEGIN {
FS = "[[:space:],]+"
OFS = ","
print "Query Start","Query End","Target Start","Target End","Score","E","P","GC"
}
/^\>g/ { Query=$0 }
/Query =/ {
query_start=$4
query_end=$6
target_start=$9
target_end=$11
}
/Score =/ {
score=$4
e=$7
p=$10
gc=$13
print query_start,query_end,target_start,target_end,score,e,p,gc
}
That work? Note the field numbers are bumped out by 1 because when you don't use the default FS awk no longer skips leading white space so there's an empty field before the white space in your input.
Obviously, you are not using your Query variable so the line that populates it is redundant.

Lua Control Statments having odd behavior

I'm getting a very unexpected result from what should be basic control statement operations. I have the following, a file being read with this sort of data:
1, 51, one , ab
1, 74, two , ab
0, 74, tree , ab
0, 74, for , ab
0, 74, five , ab
My snip of Lua code that processes it:
if file then
for line in file:lines() do
LineArray = line
CanClaimInfo[LineArray] = {}
lineData = utils.split(line,",")
if lineData[1] == "0" then
lineData[1] = "CAN A"
elseif lineData[1] == "1" then
lineData[1] = "CAN B"
else
lineData[1] = lineData[1]
end
CanClaimInfo[LineArray]["CANBus"] = lineData[1]
CanClaimInfo[LineArray]["Address"] = lineData[2]
CanClaimInfo[LineArray]["Name"] = lineData[3]
end
and I get this as an output:
CAN A 74 for
CAN A 74 tree
CAN A 74 five
CAN B 74 two
1 51 one
I don't get how it slips through the elseif lineData[1] == "1" then bit. I checked and there are no lead/trailing white spaces or anything like that. Any ideas?
Maybe utf-8 encoding bytes at the beginning of file? Try printing lineData[1] before the "if" tests to see what it is, and print(#lineData[1]) to see how many chars it has. Likely more than 1 char so it ends up in that third branch (else):
lineData = utils.split(line,",")
print(#lineData[1]) -- likely prints 1 for all but first line
if lineData[1] == "0" then
To find the extra bytes, try print(string.byte(lineData[1], 1, #lineData[1])).
Hm, seems like your utils.split function has some problems. I used a function from http://lua-users.org/wiki/SplitJoin and it works quite well with your code:
utils = {
split = function(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
}
Maybe your function converts the 1 to a number (for whatever reason). In Lua, "1" ~= 1!