I'm trying to change the text of a token using the C target.
From the docs for the SETTEXT macro: "However if you wish to change the text that the token represents you can use this macro to set it explicitly."
TOKEN: 'token' { SETTEXT("text"); }
SETTEXT is expecting a pANTLR3_STRING. How can I provide it one for a string literal?
Or is there another way of doing this..?
Thanks
Related
I'm trying to match an obtained property from one class with another class's same property at run time. After some research, I found out that there is such thing as "Reflection" in .net but Im using just VBA. Just for background: I'm automating an application using this code, so some objects are exposed, while others are not.
The way I'm currently doing it is using a property of obtained class "Description", and use that to search for the same property at the targeted class.
Set TargetVar = hySetOperations.Item(j).TargetVariable 'This is a RealVariable a property that refers to a class
Set SourceObj =hySetOperations.Item(j).SourceObject 'This is also a RealVariable
'In order to import variable from source object, we r gonna use TargetVariable description and truncate space, and use it (This might not work if description
'is different than actual name of the variable)
Dim RealVarString As String
RealVarString = TargetVar.Description
'Trim spaces
RealVarString = Replace (RealVarString, " ", "")
Set SourceVar = CallByName ( SourceObj, RealVarString, vbGet)
This actually works for most of the cases since "description" is usually the same as property's name, but with spaces. However, in some cases, this is not the case, in which things go south.
I have a string similar to below
"OPR_NAME:CODE=value,:DESC=value,:NUMBER=value,:INITIATOR=value,:RESP"
I am using StringTokenizer to split the string into tokens based on the delimiter(,:),I need the values of
CODE,DESC and NUMBER.
Can someone pls tell how to achieve this ? The values may come in random order in my string
For eg my string may be like below as well :
"OPR_NAME:DESC=value,:NUMBER=value,:CODE=value,:INITIATOR=value,:RESP" and still it should be able to fetch the values.
I did below to split the string into tokens
StringTokenizer st = new StringTokenizer(str,",:");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
But not sure how to store these tokens to just get the value of 3 fields as mentioned above.
Thanks !!
Okay so what I meant is, detect where is the "=" and then apply a substring to get the value you want.
rough example
System.out.println(st.nextToken().substring(st.nextToken().indexOf('=')+1,st.nextToken().length()));
Use split instead :
String[] parts = X.split(",:");
for (String x:parts) {
System.out.println(x.substring(x.indexOf('=')+1));
}
I want to initiate a worksheet with a JavaScript object which looks like { "A1:B2": [["01", "02"], ["03", "04"]], "C5": [[4]] }, I have the following code:
function sheetIni(data) {
return Excel.run(function (ctx) {
var sheet = ctx.workbook.worksheets.getActiveWorksheet();
for (var key in data) {
if (data.hasOwnProperty(key)) {
var range = sheet.getRange(key);
range.values = newData;
};
}
return ctx.sync().then(function () {
console.log("done")
})
})
};
I realise that the result in the worksheet turns out to be respectively 1, 2, 3, 4 in A1, B1, A2, B2; it converts automatically a string to a number (eg, "02" to 2).
Does anyone know how to avoid this automatic conversion?
In general, how could I make sure a javascript value can be faithfully assigned to a cell value without extra conversion?
The safest thing to do, when assigning data to arbitrary cells, is to set number formatting first, and then the value.
For text strings, the "#" number format serves as a way of declaring "I want this cell to contain a text string, even if it comes in as a number". It's the same as the user entering values into Excel manually.
For future reference: if you want a working code snippet back, the easiest way of ensuring it is to first create and share a snippet using Script Lab and share a link to it in the question. That way, it would be very easy for someone like myself to import the code, make a quick tweak, and send you a final snippet back.
Another way is to prepend numbers that you want to be treated as text with a '
[["'01", "02"], ["'03", 4]]
will result in excel
[["01", 2], ["03", 4]]
This avoids having to format cells as Text (which can have nasty side effects)
When retrieving an array of values from Excel you can load types as well as values and then loop the array prepending text numbers with ' before sending the array back to Excel.
I have correlated the Token value taken from the following response snippet:
result.sessionToken = '7AFF3BA8\x2DD913\x2D4211\x2D990E\x2D7DF3AB5687B7';
Using the web_reg_save_param function as:
web_reg_save_param(
"TOKEN",
"LB=result.sessionToken = '",
"RB=';",
"ORD=1",LAST);
But in a later request I need to send the correlated value in the below format:
7AFF3BA8-DD913-4211-990E-7DF3AB5687B7
The value \x2D is to be substituted by -.
I am right now using the below 'C' and LR code for this:
strcat(pstr1,lr_eval_string("{RToken}"));
strcat(aSeparator,"\\");
for(a=0,b=0;pstr1[a]!=NULL;a++,b++)
{
if(pstr1[a]==aSeparator[0])
{
strcat(pstr2,"-");
pstr2[b+1]=pstr1[a+4];
a=a+5;
b=b+2;
}
pstr2[b]=pstr1[a];
}
lr_save_string(lr_eval_string(pstr2), "sessionToken");
I wanted a generic and another approach for this problem. I don't want to use web_convert_param function, but if there is a hidden trick to convert the string as desired I would like to know.
Thanks,
Ritika
Try This...lr_save_string(lr_eval_string("{TOKEN}"),"convertedtkn");
Question : Is there a way to have direct access to a specific cell in vtkPolyData structure?
I'm using vtkPolyData to store sets of lines, say L.
Currently, I'm using GetLines() to know the number of lines in L. Then, I have to use GetNextCell to go through this set of lines using a "while" loop.
Current code is something like:
vtkSmartPointer<vtkPolyData> a;
...
vtkSmartPointer<vtkCellArray> lines = a->GetLines();
...
while(lines->GetNextCell(numberOfPoints, pointIds) != 0)
-> I'd like to be able to work directly on a specific line by doing something like:
myline = a[10];
doSomething(myline);
you could get an access to a specific cell using vtkDataSet::GetCell(vtkIdType cellId) function