Help with NI-DAQ Example Code
Hi. I've just started working with the NI ISB-6211. This is the first ACD i've ever used, so i'm farily new to this. I have quite a bit of knowledge in programming. After searching through the installation files I found some example C Code that runs in the command prompt. I've modified one quite a bit to get it to do what I want. My question is...
Now, i'm having some issues. I'm trying to get it to print a voltage reading into the command prompt. I've hooked it all up and i've used labview to make sure everything is working as it should (Which it does!). When I compile the C program and run it, instead of returning a voltage it just aquires points, and I really have no idea what these "points" are.
Here is the main part of the example code:
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,1.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));
// DAQmx Start Code
DAQmxErrChk (DAQmxStartTask(taskHandle));
// DAQmx Read Code
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL));
printf("Acquired %d points\n",read);
Error:
And then it just moves down to the exit clause. Is there any documentation anywhere which tells me which DAQ command I need to use to print a continuously updating voltage read out? (Just as a decimal, like 5.21V for example).
Thank you all
John
Solved!
Go to Solution.
John,
The data acquired by DAQmx is written into the array called 'data'. The number of points DAQmx wrote into this array is stored in the variable 'read' which was passed in by reference. To print the values returned, you'd need to loop over the 'data' array, and print each value. See this help topic for an explanation of DAQmxReadAnalogF64.
Dan
Similar Messages
-
Query Help with Item Master & Warehouse Code
Forum,
I would like help with a query to identify any items within a database where a particular warehouse code does NOT exist against it. At present I have the following:
select T0.ItemCode, T1.WhsCode from OITM T0
INNER JOIN OITW T1 on T0.ItemCode = T1.ItemCode
where T0.ItemCode NOT IN ('WHS1')
This is returning all other instance and not just a list of item codes where 'WHS1' is missing from within the 'Stock Data' tab.
Thanks,
SarahHi Sarah...
Try This
SELECT T0.ItemCode, T0.ItemName, T1.WhsCode
FROM OITM T0 INNER JOIN OITW T1 ON T0.ItemCode = T1.ItemCode
WHERE T1.WhsCode not in ( 'WHS1')
Regards
Kennedy -
Need help with CONTACT sync example
I have been trying to work with the Sync example that utilizes the MEREP_CONTACT_* BAPI wrappers. Is there anyone who has been able to get this example to work that could give more information on it? I can create the programs, but cannot get data to it. Which SyncType is it supposed to use? What directory do you create the data from MEREP_SAP_EXM002_DATA_GEN1?
Any information would be greatly appreciated.
Thanks
Brian Timothy
[email protected]hello brian,
i created the contactaddress test application and used these BAPIs on the backend mapped to syncBos SAP_EXM001 and SAP_EXM002. the basic requirement for this is to deploy your application together with the xml metadata.
after your application is installed in the ME, the framework will automatically send a data download request for syncBos SAP_EXM001 and SAP_EXM002 on the next synchronization. Prior to this, the application tables in the backend like the MEREP_PERSON which is mapped to the syncbo SAP_EXM002 should be filled with data.
use MEREP_SAP_EXM002_DATA_GEN2 and MEREP_SAP_EXM001_DATA_GEN1 to fill-up the tables with data.
you should have at least a data viewer for the corresponding syncbo data on your application.
hope this helps.
regards
jo -
Help with java digital signing code
hello people.
can anybody help me?
i have find a java code to resolve my problem with sending pay in soap envelope with digital signature and attached certificate. i compiled it with jdk jdk1.6.0_37. and it works.
i need it to work in built-in jvm in oracle 9i. in oracle 9i jvm release is 1.3.1. Java code does not work there. there is an error
class import com.sun.org.apache.xerces.internal.impl.dv.util.Base64 not found in import.
i did not find this class in network.
can anybody help with rewriting it for jvm 1.3.1?
thanks in advance.
code below:
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import java.io.*;
import java.security.Key;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.cert.Certificate;
public class Sign {
public static void main(String[] args) throws Exception {
// TODO code application logic here
BufferedReader reader = new BufferedReader(new FileReader("c:\\cert.p12"));
StringBuilder fullText = new StringBuilder();
String line = reader.readLine();
while (line != null) {
fullText.append(line);
line = reader.readLine();
KeyStore p12 = KeyStore.getInstance("pkcs12");
p12.load(new FileInputStream("c:\\cert.p12"), "Hfrtnf$5".toCharArray());
//????????? ????????? ????, ??? ????? ????? ???????????? alias ? ??????
//Key key = p12.getKey("my kkb key", "ryba-mech".toCharArray());
Key key = (Key) p12.getKey("my kkb key", "Hfrtnf$5".toCharArray());
Certificate userCert = (Certificate) p12.getCertificate("my kkb key");
String base64Cert = new String(Base64.encode(userCert.getEncoded()));
//signing
Signature signer = Signature.getInstance("SHA1withRSA");
signer.initSign((PrivateKey) key);
signer.update(fullText.toString().getBytes());
byte[] digitalSignature = signer.sign();
String base64sign = new String(Base64.encode(digitalSignature));
String base64Xml = new String(Base64.encode(fullText.toString().getBytes()));
System.out.println("<certificate>" + base64Cert+"</certificate>");
System.out.println("<xmlBody>" + base64Xml+"</xmlBody>");
System.out.println("<signature>" + base64sign+"</signature>");
Edited by: user13622283 on 22.01.2013 22:08My first search is to see if there is an Apache commons project that provides it. Lo and behold:
http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
commons-codec. -
Help with some java login code
hey,
I am a new member but used to visit the site regularly. I am undergoing a java project and I cannot seem to get my head around how to code when users log in, there name must appear at the top of each page they visit.
User enters name into a text box. Do I use getter and setter methods? any bit of help would be of some advantage to me.
Thanks for your time and I'll help with anyone else who is stuck.if JSP or servlet use Session...
if you are using frame you have to consider... which frame is a top parent. that top frame will have the set and get method.. for you to set and retrieve the user name.. bear in mind that different object will have different user...
so you have to play fair game ...hehehehe :-) -
Need help with this Pascal Triangle code....
Hey everyonr i am totally new to Java... so need your help with this code...
the function makeRows gives me problems... main is correct ... can someone fix my makeRows... i don't see what's wrong
public class Pascal {
/** Return ragged array containing the first nRows rows of Pascal's
* triangle.
public static int[][] makeRows(int nRows) {
int[][] mpr = new int[nRows+1][];
int l=0; int r=0;
for (int row = 0; row < nRows; row++) {
mpr[row] = new int[row+1]; //index starts at 0
if (row==0) {
mpr[0][0]= 1;
if (row==1) {
mpr[1][0]= 1;
mpr[1][1]= 1;
if (row>=2) {
for (int j = 0; j <= row; j++) {
if (j==0) {l=0;} else {l=mpr[row-1][j-1];}
if (j==mpr[row].length-1) {r=0;} else{r=mpr[row-1][j];}
mpr[row][j] = l + r;
return mpr;
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("usage: java " + Pascal.class.getName() + " N_ROWS");
System.exit(1);
int nRows = Integer.parseInt(args[0]);
if (nRows > 0) {
int[][] pascal = makeRows(nRows);
for (int[] row : pascal) {
for (int v : row) System.out.print(v + " ");
System.out.println("");
}this makeRows function should return ragged array containing the first nRows rows of Pascal's triangle
thanks
Edited by: magic101 on May 9, 2008 4:03 PMmagic,
i think corlettk meant that some people might not know what pascal's triangle is.
also, you didnt say what was wrong with your code, just that it was wrong.
asking smart questions is about giving as much information you can to get the
best answer. i would throw a System.out.print between every line of your
algorithm. i would also supply us with the values you are getting for each row.
also, this question is asked all the time here. do a forum search.
1
11
121
1331
14641 -
HELP WITH AN OLDER VERSION CODE!!!!!
I am trying to figure out how to convert a code from an older version into JDK1.3.1_01.
Please HELP!
Here is my code............
mport java.awt.*;
import java.applet.*;
public class Race extends Applet {
private Button myButton; //use a button to start the race.
int race_square; //record the race square 70.
int t_square; //record the tortoise's position.
int h_square; //record the hare's position.
int clock; //record clock ticks.
public void init()
myButton=new Button("Start Clock") ; //add button to the top of panel.
add("North",myButton);
reset_v();
public void reset_v()
race_square=70; // total squares is 70
t_square=1; //start point =1
h_square=1; //start point=1
clock=0; //reset the clock to zero.
public void race() {
int i=0; //set some integer varibles.
int t_random=0; //random number for tortoise.
int h_random=0; //random number for hare.
Graphics g=getGraphics(); //define graphics.
Rectangle r = bounds(); //define painting boundary.
g.drawString("BANG !!!!!",100,r.height/2-80);
g.drawString("AND THEY'RE OFF !!!!!",100,r.height/2-70);
g.drawString(Integer.toString(clock),r.width/2,50); //show the zero clock time.
do{
try { Thread.sleep(1000);} //clock ticks 1 second.
catch (InterruptedException e){}
clock++;
g.setColor(Color.lightGray); //clear all the old drawings
g.fillRect(0,0,r.width,r.height);
g.setColor(Color.black);
g.drawString(Integer.toString(clock),r.width/2,50); //show the clock time.
t_random=getrandom(); // FOR TORTOISE
if (t_random<=5) t_square+=3; // 50% fast plod: 3 squares to the right.
else if (t_random>5 && t_random<=7)t_square-=6; // 20% slip: 6 squares to the left.
else t_square+=1; // 30% slow plod: 1 square to the right.
h_random=getrandom(); //FOR HARE
if (h_random<=2) {} // 20% sleep: not move at all.
else if (h_random>2 && h_random<=4)h_square+=9;// 20% big hop: 9 squares to the right.
else if (h_random==5) h_square-=12; // 10% big slip: 12 squares to the left.
else if (h_random>5 && h_random<=8)h_square+=1;// 30% slow hop: 1 square to the right.
else h_square-=2; // 20% small slip: 2 aquares to the left.
if(t_square<=0) t_square=1; //always start from 1.
if(t_square>race_square)t_square=race_square;
if(h_square<=0) h_square=1; //always start from 1.
if(h_square>race_square)h_square=race_square;
g.setColor(Color.red); //draw the tortoise's path: use red color.
g.fillRect(5,r.height/2-5,5*t_square,5);
g.drawString("T",5*t_square,r.height/2-7);
g.setColor(Color.blue); //draw the hare path: use blue color.
g.fillRect(5,r.height/2+1,5*h_square,5);
g.drawString("H",5*h_square,r.height/2+17);
g.setColor(Color.black); //draw the race squares.
g.drawLine(5,r.height/2,5+5*race_square,r.height/2);
for(i=5;i<=5+5*race_square;i+=5)
g.drawLine(i,r.height/2-5,i,r.height/2+5);
if (t_square==h_square &&t_square!=race_square) // tortoise bites the hare.
g.drawString("OUCH!!!",5+5*h_square,r.height/2-16);
}while ( t_square=race_square && h_square=race_square && t_square<=5+5*race_square;i+=5)
g.drawLine(i,r.height/2-5,i,r.height/2+5);
g.drawString("T",5,r.height/2-7); //mark tortoise
g.drawString("H",5,r.height/2+17); //mark hare
public int getrandom()
return( 1+(int)(Math.random()*10)); // generating the random number 1 to 10.
public boolean action(Event e, Object arg)
if (e.target instanceof Button)
reset_v(); //reset the initial variables.
race(); //use the button the start the race.
return true;You posted this yesterday, at
http://forum.java.sun.com/thread.jsp?forum=54&thread=185330
The code you've posted doesn't seem to include Ilikejava's suggested changes - which are, as far as I can tell, the major changes required to bring your applet in line with Java 1.3.
It will be easier to help if you show what is wrong with your code, if it's generating a compiler error message or throwing an exception.
Regards,
-Troy -
Help with understanding multi-threaded code
Hi Everyone,
I am currently reading a book on multi-threading and up until recently I have been able to understand what is going on. The thing is the complexity of the code has just jumped up about two gears without warning. The code is now using inner classes which I am trying to develop an understanding of but I am not finding it easy going, and the book has been lite on explanations. If anybody can help with the following code it will be really appreciated.
public class SetPriority extends Object
private static Runnable makeRunnable()
Runnable r = new Runnable()
public void run()
for(int i=0; i<5; i++)
Thread t = Thread.currentThread();
System.out.println("in run() - priority=" + t.getPriority() +
", name=" + t.getName());
try{
Thread.sleep(2000);
}catch(InterruptedException x){
//ignore
return r;
public static void main(String[] args)
Thread threadA = new Thread(makeRunnable(), "threadA");
threadA.setPriority(8);
threadA.start();
Thread threadB = new Thread(makeRunnable(), "threadB");
threadB.setPriority(2);
threadB.start();
Runnable r = new Runnable()
public void run()
Thread threadC = new Thread(makeRunnable(), "threadC");
threadC.start();
Thread threadD = new Thread(r, "threadD");
threadD.setPriority(7);
threadD.start();
try{
Thread.sleep(3000);
}catch(InterruptedException x){
//ignore
threadA.setPriority(3);
System.out.println("in main() - threadA.getPriority()=" + threadA.getPriority());
}My greatest challenge is understanding how the makeRunnable() method works. I don't understand how this inner class can be declared static and then multiple "instances" created from it. I know that I have no idea what is going on, please help!!!
Thanks for your time.
Regards
Davo
P.S.: If you know of any really good references on inner classes, particularly URL resources, please let me know. Thanks again.Yikes!! The good news is that you're unlikely to see such convoluted code in real life. But here we go.
"private static Runnable makeRunnable()" declares a method that returns objects of type Runnable. The fact that the method is declared "static" is pretty irrelevant - I'll describe what that means later.
The body of the method creates and returns an object of type Runnable. Not much special about it, except that you can give such an object to the constructor of class Thread and as a result the run() method of this Runnable object will be called on a new thread of execution (think - in parallel).
Now the way it creates this Runnable object is by using the "anonymous inner class" syntax. In effect the method is doing the same as
public class MyNewClass implements Runnable {
public void run() {
// All the same code inside run()
public class SetPriority {
private static Runnable makeRunnable() {
Runnable r = new MyNewClass();
return r;
// The rest of the original code
}Except you don't bother declaring MyNewClass. You're not interested in defining any new method signatures. You just want to create an object that implements Runnable and has certain instructions that you want inside the run() method. Think of the whole approach as shorthand.
Think about this for a while. In the mean time I'll write up the "static". -
Elasticity: help with converting Flash 5 code to Flash 8
Hello
because I have to make a flash menu with elasticity effect I
came upon this tutorial:
http://www.kirupa.com/developer/actionscript/spring.htm
All OK but the code there works only with Flash 5. I somehow
managed to concoct code that works for Flash 6 but still I didn't
come even close to a code working in Flash 8. I'm using
Actionscript only from version 7, I do not know anything about
Flash 5 and 6. So please, the more experienced guys, help me!!
The code I concocted is:
MovieClip.prototype.move = function (centerx, centery,
inertia, k) {
this.x = -this._x+centerx;
this.y = -this._y+centery;
this.xp = this.xp*inertia+this.x*k;
this.yp = this.yp*inertia+this.y*k;
this._x += this.xp;
this._y += this.yp;
onEnterFrame=function() {
this.move (_root._xmouse,_root._ymouse,0.9,0.1) ;
This whole code is on the timeline of the MC being moved.
So now the only thing I need is to make this code work for
Flash 8
Please, helpJust managed to do it !
-
Ask for help with LabView Daq and Tek VX4244 VX4101
I use NI VIO-MXI-64XE-10, Tek VX4101 and Tek VX4244 to acquire data in one
Tek 1410A VXI mainframe connected a PII 350/64M computer with MXI2
cable.these modules are used for three independent applications,the datum
are acquired and through preliminary computation, then sent to three TCP/IP
ports the computer served in real time. the burden of the system will be
very heavy because the 64XE-10 need to use up the 100K sample rate
continuously dealed by 50 channels,and the VX4244 need about 30Hz for all 16
channels.
64XE-10 is easily detected by NI software, and I can use LabView Daq
intermediate analog input VIs to acquire data in background, read 50 samples
and compute the mean for each channel,then packa
ge the 50 mean and send to
client end with 40 times a second. I found the speed is satisfactory.
As for VX4244 and VX4101,I can't use LabView Daq VIs,and the driving
functions for LabView with the product are difficult to understand, I want
to know how I can get data and send out efficiently,how to get data in
background,and how to use FDC ?
And for 64XE-10, although the speed is satisfactory, but it use much more
CPU resource, I want to use advanced analog input VIs to build the code,I
want to know where I can find examples using the advanced analog input VIs ?
Best RegardsI use NI VIO-MXI-64XE-10, Tek VX4101 and Tek VX4244 to acquire data in one
Tek 1410A VXI mainframe connected a PII 350/64M computer with MXI2
cable.these modules are used for three independent applications,the datum
are acquired and through preliminary computation, then sent to three TCP/IP
ports the computer served in real time. the burden of the system will be
very heavy because the 64XE-10 need to use up the 100K sample rate
continuously dealed by 50 channels,and the VX4244 need about 30Hz for all 16
channels.
64XE-10 is easily detected by NI software, and I can use LabView Daq
intermediate analog input VIs to acquire data in background, read 50 samples
and compute the mean for each channel,then packa
ge the 50 mean and send to
client end with 40 times a second. I found the speed is satisfactory.
As for VX4244 and VX4101,I can't use LabView Daq VIs,and the driving
functions for LabView with the product are difficult to understand, I want
to know how I can get data and send out efficiently,how to get data in
background,and how to use FDC ?
And for 64XE-10, although the speed is satisfactory, but it use much more
CPU resource, I want to use advanced analog input VIs to build the code,I
want to know where I can find examples using the advanced analog input VIs ?
Best Regards -
Need help with simple VS2005 C++ code
I'm not sure if I am doing something wrong, or if the Switch Front Panel isn't expected to reflect the results of my code. I have a virtual 1163 cart setup in MAX. I start the Switch Soft Front Panel and can see the state of the channels. I have auto refresh turned on.
My C++ code has a task generated by the .mxb file. The channel is configured this way:
void CDAQmxTask::Configure()
CNiDAQmxDOChannel ch = DOChannels.CreateChannel("SC1Mod6/port0/line2", "DigitalOut", DAQmxOneChannelForEachLine);
ch.InvertLines = false;
For simplicity sake, I create a gobal instance of this class at the top of the dlg class file:
CDAQmxTask task;
I have a single button that when pressed should turn on channel 2
void CFVT_TestAppDlg:nBnClickedButton1()
task.Stop();
CNiDAQmxDigitalSingleChannelWriter* writer = new CNiDAQmxDigitalSingleChannelWriter(task.Stream);
writer->WriteSingleSampleSingleLine(TRUE, TRUE);
delete writer;
Should I expect to see teh results of this code in either the Schematic or Relays tab of SwitchSoft FP?AiR_GuNNeR,
You will not see the NI-Switch Soft Front Panel (SSFP) update to reflect the results of your Visual Studio code. This is because NI-Switch is an IVI compliant driver, and IVI compliance for switches requires the driver to be able to open multiple driver sessions with one switch. As a result, your C++ program and the SSFP have each established a seperate, independant IVI driver session to the switch.
For example, if your C++ program instructs Relay 1 to close, the relay will close. Then, if the SSFP instructs Relay 1 to close, nothing will happen since the relay is already closed. The SSFP can also instruct Relay 1 to open, and it will, regardless of the fact that your C++ program gave no such command.
As a result, it is important that for switching applications, you be sure that you only have one session open to a given switch at a time, otherwise you may see unexpected behavior. This can even happen within an application.
You can lock a session within your application so that no other thread in your application can access that driver session. Do this using the niSwitch_LockSession function. You can find more information on this function in the NI-Switch shipping help.
Seth B.
Staff Test Engineer | National Instruments
Certified LabVIEW Developer
Certified TestStand Developer
“Engineers like to solve problems. If there are no problems handily available, they will create their own problems.”- Scott Adams -
Help with a simple pause-code function
For a week I've been trying to figure out a simple pause-code
function fror AS 3.0. I need something that pauses AS code for set
amounts of time. People have tried to help me on this forum, but
I've still not been able to make the code work.
Here is what I have at the moment for pause-code (not
working):
var intID;
intID = setInterval(delay, 3000); //this tells flash to wait
3 seconds
function delay(){
clearInterval(intID);
_root.gotoAndPlay(1); // or do something else...
The person who supplied me with this code did not include the
first line "var intID", but as a new flash user, I wasn't sure how
else to declare intID. Could someone with some flash experience
walk me through the steps of creating a pause-code function or add
to the one I have already provided. When I use the above code in my
flash document, the pause feature does not work at all. It
essentially skips over the setInterval and clearInterval functions
and plays the root clip in delay(). I need code meant for AS 3.0
and I'm becoming increasingly desperate for a response.
I hope this is understandable and thank you for taking a
look,
SamHello KGlad,
Thankyou for that information. I had no idea lol. Could you
please clarify and explain a little more about using the timer
class to delay execution of code? Possibly provide an example? I
would be very grateful.
Thanks,
Sam -
Help with my Flash Builder code.
Hello,
I am getting two errors, well four but three are the same. 1083 && 1084.
here is my code, can someone look over it and tell me what I am doing wrong. I am fairley new to Flash Builder so please no harassement.
//Check The Login
var userName: String= "requestofone";
var passWord: String= "robots96";
if (userName == "requestofone" && passWord == "robots96"){
trace("Welcome requestofone")
}else{ (userName != "requestofone")
trace("User not found. Try again.")
}else if{ (passWord != "robots96")
trace("Password does not match our records.");
//Tire Pressure
var frontTires:Array = ['43', '43'];
var rearTires:Array = ['45', '45'];
if (frontTires:Array != uint: 43 && rearTires:Array != uint: 45){
trace("Get Your Tires Checked Out")
}else{ (frontTires:Array == uint: 43) && (rearTires:Array == uint:45)
trace("Tires pass the spec")}
Description
Location
1083: Syntax error: else is unexpected.
line 48
1084: Syntax error: expecting rightparen before colon.
line 56
1084: Syntax error: expecting rightparen before colon.
line 58
1084: Syntax error: expecting rightparen before colon.
line 58
I have been trying to figure this out for a while now. Please help.Not to be nasty or "harass", but you need to go back and learn the syntax. Each line of code should end with a semicolon, and I'm also not sure what you are trying to accomplish with your "else{(userName != "requestofone")". Are you trying to do a conditional test? If so you need to use an "else if". That said, the "else if" you do use is incorrect. The parens should come out side the curly braces like you did for the initial "if" condition, and the "else if" needs to come before your final "else" since that is where the flow will go when no previous condition is met.
Example:
if (a == b){
trace("do something");
else if (b == c){
trace("do something different");
else{
trace("do some default thing");
I hope this helps. -
Help with the File Reader code
Hi ALL!
I'm novice to Java, so, I would appreciate any help and please take into account that I just start learning Java. Thanks in advance!
So, I wrote Java program to read data from file and output it to the console.
Here's the code:
package files;
import java.io.*;
public class FlatReader{
public String getText(File file, String encode) throws IOException {
BufferedReader inputStream = null ;
String str="";
try {
inputStream = new BufferedReader(new InputStreamReader(new FileInputStream(file), encode));
do {
str+=inputStream.readLine();
while (inputStream.readLine()!=null);
PrintStream sysout = new PrintStream(System.out, true, "UTF-8");
sysout.println(str);
return str;
} finally {
if (inputStream != null) {
inputStream.close();
public static void main (String args[])
File file = new File("d:\\temp.txt");
FlatReader flat = new FlatReader();
try {
flat.getText(file, "UTF-8");
catch(IOException err)
}Everything works fine but if you have a file with three lines for example:
Line1
Line2
Line3
then my program will return only Line1 and Line2
I know that I can use something like
while (str=inputStream.readLine()!=null);
instead of do while...but that does not work for me because the whole idea is that I should get the correct value in my str variable when I return it in the method, i.e. return str and str should have
Line1
Line2
Line3
Could you please help me to figure it out?
Thanks!do {
str+=inputStream.readLine(); // Here you're reading a line
while (inputStream.readLine()!=null); // And here you're reading another one (and thus skipping it) -
Need urgent help with LayerManager (easy example)
Im trying to get a scrolling effect by moving the view window.
THE PROBLEM IS that if I move the view vindow the Sprite (spriteTest) is displayed at the new position AND still at the old position. I don't want it to be displayed on the old position. So if I move it a pixel every 5 ms I get a trail of the Sprite. Why does it happen??? (clueless)
Here is the code...
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.LayerManager;
import javax.microedition.lcdui.game.Sprite;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class Game extends GameCanvas implements Runnable
private Thread t; //the thread running the game
private Midlet midlet; //the midlet
private int DISP_WIDTH; //the width of the display
private int DISP_HEIGHT; //the height of the display
private int xpositionView, ypositionView; //the x and y coordinates of the view window (used for scrolling)
private LayerManager world; //the layermanager in which all sprites are added
private Sprite spriteTest; //a Sprite with an image looking like a goomba from super mario
/** Creates a new instance of Game */
public Game(Midlet midlet)
super(true);
this.midlet = midlet;
xpositionView = 1;
ypositionView = 1;
DISP_WIDTH = getWidth();
DISP_HEIGHT = getHeight();
world = new LayerManager();
world.setViewWindow(xpositionView, ypositionView, DISP_WIDTH, DISP_HEIGHT);
try
spriteTest = new Sprite(Image.createImage("/images/goomba.png")); //creates the sprite containing an image (no frames only 1 picture)
catch(Exception e)
System.out.println("Couldn't load sprite image!");
spriteTest.setPosition(190, 30); //sets the position of the sprite
world.append(spriteTest); //appends the sprite to the LayerManager
/* The game loop */
public void run()
Graphics g = getGraphics();
while(true)
move();
render(g);
try
t.sleep(5); //sleeps for 5 ms
catch (InterruptedException ie)
/* Moves the view window to the right*/
private void move()
xpositionView = xpositionView + 1; //update position 1 pixel to the right
world.setViewWindow(xpositionView, ypositionView, DISP_WIDTH, DISP_HEIGHT); //sets the view window to the new location
/* Render the graphics. !!!!PROBLEM!!! */
public void render(Graphics g)
world.paint(g, 0, 0); //paints out the LayerManager
flushGraphics();
/* Starts the thread */
public void start()
t = new Thread(this);
t.start();
}I already do sleep the Thread 5 milliseconds.
I've uploaded pictures and other to make you understand the problem:
http://www.freewebs.com/scrolling/picture2.jpg
Here is the entire project (its only 122 kb small) if you can help me I would love you forever :) When you run this you will understand the problem.
http://www.freewebs.com/scrolling/ScrollingSimple.rar
Im desperate for help :(
Maybe you are looking for
-
I have a talktalk email account but cannot send emails from my iphone 3GS! Help!!!!
-
Error while installing the database 11gR2
HELLO, INS-08109 unexpected error occured while validating inputs at state 'nodeSelectionPage' Cause:No additional information available Action: Contact Oracle Support services or refer to the software manual in the stack trace log: ---# Begin Stackt
-
hello,im new here.i recently got a wirless router and reciever.on the computer that recieves the wireless via the reviever (WUSB54GS) the internet keeps disconnecting,then reconnecting two seconds later.i notice this because of the little computer in
-
can i use acrobate x pro to convert arabic PDF to word file without loosing the original format
-
Target field without origin - ODI 11 G
What is soluciton for target field without origin? Help me