I need some help with variable inheritance in VC form app! I have this code:
string ks;
ifstream sfile(ks);
if (sfile)
{
PatInfo ^ form = gcnew PatInfo;
form->ShowDialog();
}
else
{
MessageBox::Show( "Please try again.");
}
I want to pass the ks string to PatInfo form. How can it be done?
Related
// Read data from XML file
public static String getElementTextByTagName(String tagName) {
try {
String dirPath = System.getProperty('user.dir') + "\\DataFiles\\TestData.xml"
List<File> xmlFiles = getXMLFilesByDirectory(dirPath);
Iterator var3 = xmlFiles.iterator();
XMLSearchResult searchResult;
do {
if (!var3.hasNext()) {
throw new ElementNotFoundInXMLException("Element Not Found");
}
File xmlFile = (File)var3.next();
searchResult = searchForElementInsideFile(xmlFile, tagName);
} while(!searchResult.isFound());
return searchResult.getElementText();
} catch (ElementNotFoundInXMLException var6) {
var6.printStackTrace();
return null;
}
}
enter image description here
The error is appearing on the do statement line and below the same for if statement
Katalon Studio uses a version of Groovy, at the time of this answer, that does not support do-while loops.
For that effect, you'll have to do something like what's outlined in this question.
Consider it a professional courtesy that I take the time to link the answer here, instead of voting to close the question because it's already answered by that other question.
Welcome to StackOverflow.
I'm trying to write a very simple C# program in VS2015. I keep getting a message "The name (variable) does not exist in the current context." This is true for both my bool variable and string variable.
namespace PTouch
{
public class PTouch
{
bool lb_rc;
string strLabel;
lb_rc = false;
strLabel = "C:\BenchTop10\Standard 1in.lbx";
bpac.Document doc = new Document();
lb_rc = doc.Open("C:\BenchTop10\Standard 1in.lbx");
if lb_rc != false
{
doc.StartPrint("", 0);
doc.PrintOut(1, 0);
doc.EndPrint();
doc.Close();
}
else
{
MessageBox.Show("Open Error: " + doc.ErrorCode);
}
}
}
There are probably several problems with this code, but the first one is error about the variables not existing in the current context.
Any assistance is greatly appreciated.
I just discovered the problem... All the code has to be inside of a method, not just the class. I added a method to the class,
public void PrintLabel()
{ bool lb_rc; ... }
All errors cleared up, except MessageBox...
Thank you,
Tracy
I need to retrieve the value from an annotation such as this one that uses a string constant:
#Component(property = Constants.SERVICE_RANKING + ":Integer=10")
public class NyServiceImpl implements MyService {
But I am getting a kind of K_UNKNOWN and the doc says "the value is an expression that would need to be further analyzed to determine its kind". My question then is how do I perform this analysis? I could even manage to accept getting the plain source text value in this case.
The other answer looks basically OK, but let me suggest a way to avoid using the internal class org.eclipse.jdt.internal.core.Annotation and its method findNode():
ISourceRange range = annotation.getSourceRange();
ASTNode annNode = org.eclipse.jdt.core.dom.NodeFinder.perform(cu, range);
From here on you should be safe, using DOM API throughout.
Googling differently I found a way to resolve the expression. Still open to other suggestions if any. For those who might be interested, here is a snippet of code:
if (valueKind == IMemberValuePair.K_UNKNOWN) {
Annotation ann = (Annotation)annotation;
CompilationUnit cu = getAST(ann.getCompilationUnit());
ASTNode annNode = ann.findNode(cu);
NormalAnnotation na = (NormalAnnotation)annNode;
List<?> naValues = na.values();
Optional<?> optMvp = naValues.stream()
.filter(val-> ((MemberValuePair)val).getName().getIdentifier().equals(PROPERTY))
.findAny();
if (optMvp.isPresent()) {
MemberValuePair pair = (MemberValuePair)optMvp.get();
if (pair.getValue() instanceof ArrayInitializer) {
ArrayInitializer ai = (ArrayInitializer)pair.getValue();
for (Object exprObj : ai.expressions()) {
Expression expr = (Expression)exprObj;
String propValue = (String)expr.resolveConstantExpressionValue();
if (propValue.startsWith(Constants.SERVICE_RANKING)) {
return true;
}
}
}
else {
Expression expr = pair.getValue();
String propValue = (String)expr.resolveConstantExpressionValue();
if (propValue.startsWith(Constants.SERVICE_RANKING)) {
return true;
}
}
}
//report error
}
private CompilationUnit getAST(ICompilationUnit compUnit) {
final ASTParser parser = ASTParser.newParser(AST.JLS8);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(compUnit);
parser.setResolveBindings(true); // we need bindings later on
CompilationUnit unit = (CompilationUnit)parser.createAST(null);
return unit;
}
I want to user sting in another class so if you know how to use? please help me.
I am using below link but it did't work for me. it return nil or fatal error.
How to call another method from another class in swift?
below code:
var objSymbol = SymbolListVC()
code = objSymbol.code
selectedMarket = objSymbol.SMarket
below Code of Symbol class:I am gating the value in code and skt
var Skt: String!
var code: String!
code = sbol?["Code"] as? String
Skt = sbol?["kt"] as? String
Thank You.
Does SymbolListVC.code have an initial value? Or do you mean to use an existing object of SymbolListVC and read the value of code from there?
Ideally, you should be using if directives if you are not certain that a variable will have a value
if let code = objSymbol.code {
//Do your processing here
}
But before that, assuming you want to use an existing instance of SymbolListVC, your code will create a new object of the class. So you might want to change that part.
var valueToPass:String!
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
println("You selected cell #\(indexPath.row)!")
// Get Cell Label
let indexPath = tableView.indexPathForSelectedRow();
let currentCell = tableView.cellForRowAtIndexPath(indexPath!) as UITableViewCell!;
valueToPass = currentCell.textLabel.text
performSegueWithIdentifier("yourSegueIdentifer", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if (segue.identifier == "yourSegueIdentifer") {
// initialize new view controller and cast it as your view controller
var viewController = segue.destinationViewController as AnotherViewController
// your new view controller should have property that will store passed value
viewController.passedValue = valueToPass
}
}
When I run this part of my program, it fails to recognize the two input statements using 'sc.nextLine();', but it accepts an entry for 'sc.next();'. Does anyone have any suggestions?
String information()
{
int l;char at;String nam,id,number;long contact;
System.out.println("\nPlease enter your name");
nam=sc.nextLine();
do
{
System.out.println("\nPlease enter your contact number");
contact=sc.nextLong();
number=Long.toString(contact);
l=number.length();
if(l<5||l>8&&l!=10)
error();
}
while(l<5||l>8&&l!=10);
System.out.println("\nPlease enter your e-mail id");
id=sc.nextLine();
int len=id.length();
for(int k=0;k<len;k++)
{
at=id.charAt(k);
if(Character.isWhitespace(at))
{
error();
break;
}
}
return nam;
}
Try sc.nextLine above the
nam = sc.nextLine();
It takes nextLine into an empty line so you need to clear the buffer first.