Quit in a loop....
Okay I have searched all over this forum for an answer to this but I can't seem to find the answer. Here is my assignment:
1) Ask the user for a value for side or to exit.
2) Read answer.
3) If user wants to exit, then quit.
4) Otherwise, change the Square object's side value.
5) Display Square's side, perimeter, and area values.
6) Return to step 1.
I have the beginning of the if statement here:
public class SquareTest {
public static void main(String args[])
Scanner input = new Scanner(System.in);
Square square1 = new Square();
System.out.printf("Please enter a length or -1 to quit: ");
int theSide = input.nextInt();
if (theSide != -1);
square1.setSide(theSide);
System.out.println();
System.out.printf("The length of a side of the square is: %d\n", square1.getSide());
System.out.printf("The perimeter of the square is: %d\n", square1.perimeter());
System.out.printf("The area of the square is: %d\n", square1.area());
else
}But I cannot seem to figure out what to put in the else statement to make it quit. Also I am assuming that this will not re-loop back to the beginning, so any HINTS on that would be wonderful! Thank you in advance!
import java.util.*;
public class SquareTest {
public static void main(String[] args) {
String message = "Please enter a length or -1 to quit: ";
Scanner input = new Scanner(System.in);
int side;
System.out.println(message);
while ((side = input.nextInt()) != -1) {
Square square = new Square(side);
System.out.println(message);
}Look Ma, no breaks!
Similar Messages
-
Quit from while loop inside a vi that run a while loop
Hello,
this is just an example
i have a led that blink inside a subvi and i what to stop it form the ui of the user (MainHelp.vi)
but because the subvihelp.vi dont know the stop button it will not stop when i klick on the stop button
How i can work it out with out using global Var
thanks for your replay.
Attachments:
MainHelp.vi 9 KB
SubVIHelp.vi 9 KBHi
Here is one method to stop a blinking VI in a SubVI. I tried not to change your version of how the blinking works. Since the subVI is running continuously this example calls the VI using static reference and using the control names. You could also use a queue to pass values to the subVI controls.
Your original VI has a lot of stuff that made no sense, so I cleaned them all out or up, so to speak.
Good Luck.
Mark Ramsdale
Attachments:
MainHelp.vi 12 KB
SubVIHelp.vi 9 KB -
Quit while loop in event structure
Hello,
I used event structure in my application and I would like to quit a while loop in an event structure when I pressed a control. But I have a problem because I'm in the event.
Do you have a solution.
Sam.
Attachments:
Problem.vi 34 KBHi,
connect a true constant to the While loop conditional terminal in the STOP event case.
See your example modified.
Good luck,
Alberto
Attachments:
Problem[2].vi 35 KB -
Best way to transfer single point data between loops on FPGA
Hi,
I used quite number of loops on FPGA and need to transfer single point datas between loops. Only the current value of data is needed so buffer is not necessary. I don't want use target scope FIFO since it require minimum 21 elements and I only need the current value. Is there other way other than local variables?
Thanks for help!
Regards,
TomHi Godel,
Since this discussion thread is over 3 years old, it would be better to start a new thread with your specific questions to get quicker help.
I did a bit of research on your question, and found this helpful White Paper (http://www.ni.com/white-paper/7727/en/) that discusses the resources used for components in LV FPGA code. For local variables (although it depends on hardware), it looks like it uses Flip-flops and LUTs.
As for using local variables with different clock rates, I found this KnowledgeBase article that might help shed some light on your question - some issues can arise from using them with more than one clock rate (http://digital.ni.com/public.nsf/allkb/C683585460E88508862570D1006B7434)
Hope this helps! Again, if you have follow-up questions, I would definitely recommend creating a new thread
Xavier
Applications Engineering Specialist
National Instruments -
How to stop a while loop which contains a timed loop
Hi,
I'm a new hand to labview, and I'm using labviw 7.1, NOT 8.x. I'm trying to do a measurement, in which the flow would look like the attached file (I have stipped all hardware related components to make it easy to read). My questions are:
1. In Loop 3, when the comparison (x>20.85) is true, Loop1, Loop2 and Loop3 are stopped, why it won't quit the while loop (I have wired it to while loop stop)?
2. When it is running, I click on stop button, why it won't stop?
Thanks!
Attachments:
SyncTimedLoop32.vi 228 KBhwm wrote:
2. When it is running, I click on stop button, why it won't stop?
The stop button is read outside of the inner while loops. So the inner while loops will continue to run until their stop conditions are met.
hwm wrote:
1. In Loop 3, when the comparison (x>20.85) is true, Loop1, Loop2 and Loop3 are stopped, why it won't quit the while loop (I have wired it to while loop stop)?
It seemed to me like it would, but sometimes it seemed like I had to set change the numeric value one more time before it would. You have a very odd structure there by placing the event structre inside the while loop with the other loops. I think you may be running into issues where events are getting queued up in the event structure, or race conditions between when the event structure might execute relative to the other loops. It is all very odd and difficult to predict all the ways these structures might interact and relative timing. Usually event structures would belong in their own parallel while loop. I think you need to rethink exactly what you are trying to do here. It probably isn't event necessary to use the stop timed structure functions. A local variable or a notified to pass the "Stop status" from loop 3 to the other loops (or the separate event structure loop to the other 3) would probably be better. -
What is memory.cpp at line 1038?
We have been running the same test in LabVIEW for a few years. Now all of a sudden, we are starting to get a memory.cpp error at line 1038. The test normally runs days at a time (~2 weeks), but we are getting this error after about 18-24 hours. Any ideas of what could cause this? Could this be caused by any Windows XP hotfixes? We are using LabVIEW 7.1 on a windows xp machine.
I've already checked out that particular site for info. And we do open and close files in our tests. And we do have quite a few loops. But it has worked with no issues for a few years and much longer time spans (and also more open/close files and loops). So after the error occurred on our only two machines (with exact set up) that run LabVIEW 7.1 (the rest are still on 6), we rolled one back to a date before all of the hotfixes occured and we have had no problems since. The second machine had an issue with rolling back so IT came and reinstalled XP. The problem is that they install an updated version and we cannot install an older one. It has Service Pack 3 in it and I think there are some hotfixes that came along with it that are the source of the problem. But I can't gaurantee it. Hopefully we'll figure it out soon.
-
Problem: Why does this only work for powers of 2?
I wrote this program to create a golf league schedule for, ideally, eight players. However I want it to be flexible enough to permit for other denominations, such as 10 or 12. When I run the program it works perfectly for any number that is a power of 2 (2,4,8,16,32,etc...) but it will not work for other even numbers such as 6,10, or 12. If anyone has any insights it would be most helpful.
*(This is my first post on this forum so if anything looks not quite right or if this post isn't worded exactly how it should be then I apologize in advance)*
Here's the three classes.
public class ScheduleDriver
public static void main(String[] args)
//instance variables
int max; //size of flight matches array
ScheduleMaster master;//instance of class
//get max number of players for flight
System.out.print("Max number of players in this flight:");
max = Keyboard.readInt();
master = new ScheduleMaster(max);
//create weekly schedules for season
master.createSchedule();
//display weekly schedules
master.displayWeekly();
}//end main
}//end ScheduleDriver
public class ScheduleMaster
//instance variables
int maxPlyrs;//maximum number of players in flight
Week[] weeklySchedule;//array of weekly matches
public ScheduleMaster(int plyrs)
//set up instance data and declare array size
maxPlyrs = plyrs;
weeklySchedule = new Week[plyrs];
//set up the size of each week's matches array
for (int pos = 0; pos < plyrs; pos++)
weeklySchedule[pos] = new Week(plyrs);
}//end for
}//end constructor
public void createSchedule()
int count = 0;//index of weeklySchedule array
final int QUIT = -1; //quit value for loop
int flag = 0; //value to continue or exit loop
//for each player A
for (int a = 1; a < maxPlyrs; a++)
//for each opponent of player A
for (int b = (a + 1); b <=maxPlyrs;b++)
//set count/index and reset flag to zero
count = (a - 1);
flag = 0;
//while still haven't found correct week for this match
while (flag != QUIT)
//if at least one of these players are already scheduled
//for a match this week
if (weeklySchedule[count].checkPlayers(a,b) == true)
//if last valid index of array has been reached
if (count == (maxPlyrs - 2))
//reset count/index to zero
count = 0;
else
//incriment count
count++;
}//end if
else
//assign this match to array of matches for week
//and then exit loop
weeklySchedule[count].setMatch(a,b);
flag = -1;
}//end else
}//end while
}//end for
}//end for
//fill in last week/position night
for (int pos = 0; pos < maxPlyrs;pos++)
//set up position match
weeklySchedule[maxPlyrs - 1].setMatch(pos + 1, pos + 2);
//incriment pos
pos++;
}//end for
}//end createSchedule
public void displayWeekly()
//for each week in schedule
for (int pos = 0; pos < maxPlyrs;pos++)
//display header
System.out.print("WEEK " + (pos + 1));
//if pos/index is 0 or even, flight plays front 9
if ((pos % 2) == 0)
System.out.println(" [FRONT 9]");
//else flight plays back 9
else
System.out.println(" [BACK 9]");
//display lines
System.out.println("----------------");
//display week's matches
weeklySchedule[pos].display();
//skip a line
System.out.println("\n");
}//end for
}//end displayWeekly
}//end ScheduleMaster
public class Week
int[] schedule; //array of players involved in matches for week
int max; //max number of players
int count = 0; //number of players currently involved in matches
public Week(int size)
//set up instance data and size of array
max = size;
schedule = new int[size];
}//end constructor
public boolean checkPlayers(int playerA, int playerB)
boolean flag = false; //flag to determine if at least one of
//the players to check are already playing
//this week
//for each element of array
for (int pos = 0; pos < max; pos++)
//if player A matches player already playing this week
if (schedule[pos] == playerA)
flag = true;
}//end for
//for each element of array
for (int pos = 0; pos < max; pos++)
//if player B matches player already playing this week
if (schedule[pos] == playerB)
flag = true;
}//end for
return flag;
}//end checkPlayers
public void setMatch(int playerA, int playerB)
//if array can take more matches
if (count <= (max - 2))
//insert players into array of active players for week
schedule[count] = playerA;
schedule[count + 1] = playerB;
//incriment count of players playing this week by 2
count = count + 2;
}//end if
else
System.out.print("No more matches can be entered!!!");
}//end setMatch
public void display()
//for every even numbered index starting at zero
for (int num = 0;num < max;num++)
//display the player at that position and the next consecutive
//player who will be his opponent for the week
System.out.println(schedule[num] + "VS" + schedule[num + 1] +
//incriment num
num++;
}//end for
}//end display
}//end WeekAh, I have discovered the problem. The reason for the infinite loop was because of the resetting of the counter/index after every successful match entry back to (a - 1). This was causing matches to be put into weeks where they didn't belong, which caused the program to infinitely loop because it couldn't find an appropriate week to place it's next match. The only time the count should be reset back to zero is when a new player A is being processed or the last valid array index has been referenced before an out of bounds exception would be thrown. I'm still not entirely sure why this doesn't occur on powers of 2 but theh again I haven't put too much thought into it having solved the initial problem! :)
Anyways thanks for the input all who posted, much appreciated.
Happy programming!!!! -
How to change desktop background in AppleScript in 10.7?
I'm just now upgrading from 10.6 to 10.7, and I'm having trouble with a script that I wrote that worked fine under 10.6. In part, it executes the following command:
osascript -e "tell application \"Finder\" to set destop picture to POSIX file \"<path>\""
to change the desktop background image to one of two different files based on other conditions.
In 10.7, this command completes with no error code, but it only changes the background of one of my four desktops. Is there a way to programmatically change the background image of all of my desktops simultaneously? Failing that, is there a way to a) find out how many desktops I have and b) loop through them, setting each of their backgrounds in turn?
I did search the web and found the following suggestion:
osascript -e "tell application \"System Events\" to set picture of every desktop to \"<path>\""
Unfortunately, that also changes only the current desktop's picture.
The larger script is in Perl, so I'd prefer a technology that works well with that language, but if I have to change to a different scripting language, that's not the end of the world.
Thanks much for any suggestions!
RichardActually, “repeat with k from 18 to (18 + N - 1)” was not a good idea, since it works only with N < 5, as I discovered after posting the script.
So here's an improved version of the previous script that should work with any number of desktops:
set theFile to POSIX file "/Library/Desktop Pictures/Isles.jpg" -- just an example
-- Find out how many desktops you have:
tell application "System Preferences"
reveal anchor "shortcutsTab" of pane id "com.apple.preference.keyboard"
tell application "System Events" to tell window "Keyboard" of process "System Preferences"
set N to count (UI elements of rows of outline 1 of scroll area 2 of splitter group 1 of tab group 1 whose name begins with "Switch to Desktop")
end tell
quit
end tell
-- Loop through the desktops, setting each of their backgrounds in turn:
tell application "System Events" to key code 18 using {control down} -- Desktop 1
tell application "Finder" to set desktop picture to theFile
repeat (N - 1) times
delay 1
tell application "System Events" to key code 124 using {control down} -- ⌘→
delay 1
tell application "Finder" to set desktop picture to theFile
end repeat -
How do I combine folders into one pdf, preserving subfolders as bookmarks?
So far I've had to go into each folder, convert its contents and name the file the same name as the folder name, and combine all of these folders. I'd like it if there were an easier way.
Hi,
sometimes ago I wrote a VBScript which may do, what you want.
Copy the attached Script into Notepad, change the settings and save it as AcMerge.vbs.
If you have produced the PDF FileList, you can double click on the VBS or Drag 'n Drop
the PDF FileList on the vbs.
HTH, Reinhard
AcMerge.vbs
REM: Insert single/multi Pdfs into one PDF, based on a filelist file
REM: to produce a file list file you can type into "Win Start" -> "Execute"
REM: cmd /c "dir c:\temp\*.pdf /b /s >c:\PdfList.tmp"
REM: where c:\temp\ is the base-folder.
REM: The "Settings.." you can change to your needs. Drag&drop for 1 filelist-file accepted.
*********Settings in File**************************
FLFile = "C:\PdfList.tmp" '//Filename for filelist-file (files to merged)
Ask = 1 '//0=don't ask for Insert;1=ask
Bookmark = 1 '//0=Insert No bookmarks; 1=Insert with BM based on Filename
InsWithBM = 1 '//1=Insert bookmarked files with BM; 0 = insert without BM
set WshShell = CreateObject ("Wscript.Shell")
set fs = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
if objArgs.Count = 1 then FLFile = ObjArgs(0)
Info = "Insert PDF-Files in Acrobat based on File-list-file."&VbCr&_
"File Name: "&FLFile &" Start now?"
OK = MsgBox(Info, vbQuestion+vbYesNo,"Insert Files") : if OK = vbNo then WScript.quit
'//Start or switch to Acrobat
WshShell.run "Acrobat.exe"
While not WshShell.AppActivate("Adobe Acrobat") : Wscript.Sleep 1000 : Wend
Set gApp = CreateObject("AcroExch.App")
gApp.Show
if not fs.FileExists(FLFile) then
MsgBox "Ups! " & FLFile & " doesn't exist? " & "Try new!", vbExclamation
WScript.quit
end if
set FLFileInhalt = fs.OpenTextFile(FLFile)
FLPOS = 1
do until FLFileInhalt.atEndOfStream
inhalt = FLFileinhalt.ReadLine
if fs.FileExists(inhalt) then
if Ask=1 then if MsgBox(FlPos&": "&inhalt, vbOKCancel + vbInformation) = vbCancel then exit do
' /->Open first File
if FLPOS = 1 then
' Set gApp = CreateObject("AcroExch.App")
Set BASFL = CreateObject("AcroExch.pdDoc")
OK = BASFL.Open(INHALT)
if not OK Then if MsgBox("Error open Basic File") then Wscript.quit
BASFL.OpenAVDoc(mid(INHALT,InstrRev(INHALT,"\")+1))
WScript.Sleep 500
Set avdoc = gApp.GetActiveDoc
Set pddoc = avdoc.GetPDDoc
Set jso = pddoc.GetJSObject
PageBAS = BASFL.GetNumPages-1
else
PageBAS = BASFL.GetNumPages
jso.pageNum = PageBAS+1
Set INSFL = CreateObject("AcroExch.PDDoc")
OK = INSFL.Open(INHALT)
if not OK Then if MsgBox("Error open InsertFile") then Wscript.quit
PageIns = INSFL.GetNumPages
OK = BASFL.InsertPages(PageBAS - 1,INSFL,0,PageIns,InsWithBM)
INSFL.Close
jso.pageNum = PageBAS+2
end if
if Bookmark = 1 then
BMNameIE = mid(Inhalt, InstrRev(Inhalt, "\")+1)
BMNameEE = left(BMNameIE, InstrRev(BMNameIE, ".")-1)
Set BMR = JSO.BookmarkRoot
BMR.CreateChild BMNameEE, "this.pageNum = " &PageBas, PageBas
end if
FLPOS = FLPOS+1
else '/-> file in Filelist (=inhalt) doesn't exist
Ok = MsgBox(Inhalt &vbCr &"File don't exist! - Continue?", vbQuestion+vbYesNo,"Insert Files")
if OK = vbNo then QUIT
end if
loop
MsgBox "DONE!" &vbCr &"Don't forget to save the File (save as)" -
Non-static method rff() cannot be referenced from a static context
I get the above error when compiling my program, can anybody see what the problem is and how to fix it? its at the readstr = rff(); part after the if (i==2)
import java.io.*;
import java.util.Vector;
public class PropertyRental
public static Vector v = new Vector();
public static String menu;
public static String pc, hn, mr, ua, readstr;
public static int i, ln;
public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public String rff()
String line="";
String data="";
try
BufferedReader br = new BufferedReader(new FileReader("properties.txt"));
line = br.readLine();
do// EOF condition
System.out.println(line);
data = data + " \n" + line;
//line = br.readLine();
while( (line=br.readLine()) != null);
catch(IOException ioe)
return data;
public static void main()
try
do
System.out.println("Welcome to your local Property Rental Company");
System.out.println("You now have the following options");
System.out.println("");
System.out.println("1. Add a Property");
System.out.println("2. Remove a Property");
System.out.println("3. Display all Properties");
System.out.println("4. Exit the Program");
System.out.println("");
i = Double.valueOf(br.readLine()).intValue();
System.out.println("");
if(i == 1)
//BufferedWriter appends to properties.txt
//Our user input buffer
BufferedReader user = new BufferedReader(new InputStreamReader(System.in));
System.out.println("--- Add a Property ---");
//User enters address
System.out.println("\nEnter postcode (Must be less than 16 characters)");
pc = user.readLine();
//If the user has entered 'q' to quit, leave this loop
System.out.println("Enter house number");
hn = user.readLine();
System.out.println("Enter monthly rent");
mr = user.readLine();
//Write our details to file
v.addElement(new PropertyToLet(pc, hn, mr));
PrintWriter outFile;
try
outFile = new PrintWriter(new FileWriter("properties.txt" ,true));
PropertyToLet obj = (PropertyToLet) (v.lastElement());
outFile.println(obj.getpc() + "," + obj.gethn() + "," + obj.getmr());
outFile.close();
catch(IOException IOE)
System.err.println(IOE + "Has occured");
if(i == 2)
try
readstr = rff();
String[] splitArray = null;
splitArray = readstr.split(",");
for(int i=0;i<splitArray.length;i++)
if (v.size()<splitArray.length)
v.addElement(new PropertyToLet(splitArray[0], splitArray[1], splitArray[2])) ;
System.out.println("\nEnter the line number of the property you wish to remove");
int ln = Double.valueOf(br.readLine()).intValue();
v.removeElementAt(ln-1);
PrintWriter outFile = new PrintWriter(new FileWriter("properties.txt"));
for (int i=0; i<v.size(); i++)
PropertyToLet obj = (PropertyToLet) (v.lastElement());
outFile.println(obj.getpc() + "," + obj.gethn() + "," + obj.getmr());
outFile.close();
catch(Exception ex)
ex.printStackTrace();
if(i == 3)
String line="";
String data="";
try
BufferedReader br = new BufferedReader(new FileReader("properties.txt"));
line = br.readLine();
int counter=0;
do// EOF condition
counter++;
System.out.println(counter + ": " + line);
data = data + " \n" + line;
//line = br.readLine();
while( (line=br.readLine()) != null);
catch(IOException ioe)
if(i == 4)
//A simple instruction that tells the user how to exit the program
System.out.println("Press the 'x' button in the corner of the window to quit");
System.out.println("Do you want to exit [y/n]");
ua = br.readLine();
}while(ua.equals ("n"));
catch(IOException ioe)
}Edited by: Atomika3000 on Apr 23, 2009 4:09 AMYou must add modifier method to be static because you access the method from the main method which is a static method
public static String rff(){
// code
} I hope it helps you, good luck. -
Sending E-Mail to all entries in a report.
Hello,
I am looking for a way to send an e-mail to all staff stored in a report based on whether they have completed their time sheet for this week or not. The e-mail will be sent to only those people that have not submitted the time sheet as a reminder.
Any help would be appreciated, thank you.Hi,
DECLARE
v_From VARCHAR2(80) := 'Your.Worst.Nightmare;
v_Subject VARCHAR2(80) := 'Time sheet due';
v_Mail_Host VARCHAR2(30) := 'smtp.MAILHOST.com';
v_Mail_Conn utl_smtp.Connection;
crlf VARCHAR2(2) := chr(13)||chr(10);
-- Read emails from table
cursor emails is select email from tbl_emp where timesheet = "N";
BEGIN
-- Sends the email to all listed
for email in emails loop
v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
utl_smtp.Mail(v_Mail_Conn, v_From);
utl_smtp.Rcpt(v_Mail_Conn, email.email);
utl_smtp.Data(v_Mail_Conn,
'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
'From: ' || v_From || crlf ||
'Subject: '|| v_Subject || crlf ||
'To: ' || email.email || crlf ||
crlf ||
'Hi,
Submit your time sheet noob.'|| crlf || -- Message body
KR,
Joe Bloggs,
UT2004 & QuakeLive player');
utl_smtp.Quit(v_mail_conn);
end loop;
EXCEPTION
WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
END;
/Alter your query so that it lists those who didn't submit their timesheets & whatever message you want appearing. You need their email storing somewhere.
You put this PL/SQL into a PL/SQL region and give it a conditional display e.g. clicking a "timesheet overdue" button.
Mike -
PL/SQL: numeric or value error (character string buffer too small)
Hi All,
Below is the procedure used to send notifications. It was working fine in previous DB version :- 10.1.0.5.0 and there was recent upgrade to 11.2.0.2.0.
I complies fine, but when executing it throws the error.
PROCEDURE PROC_STATUS_MAIL_UNADJ IS
K_BOUNDARY CONSTANT VARCHAR2(1000) := 'a1b2c3d4e3f2g1';
l_analysis_report VARCHAR2(32767); --empty_clob; --clob :=
l_header VARCHAR2(1000);
l_footer VARCHAR2(200);
cnxn UTL_SMTP.connection;
cursor cloc is select location_id from locations order by location_id asc;
loc_id cloc%rowtype;
BEGIN
dbms_output.enable (1000000);
FOR loc_id in cloc
loop
l_analysis_report := '<style type="text/css">
<!--.style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; font-style: normal; color: #FF0000}-->
<!--.sidebar1 { font-family: Arial, Helvetica, sans-serif; font-size: 10px}-->
<!--.text { font-family: Arial, Helvetica, sans-serif; font-size: 12px}-->
</style>
<center><b><font face="Arial">Run Summary Report'
|| TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI AM') || '<br><br></font></b></center>'
|| ' <div align="center"><table width="95%" border="1" cellspacing="0" cellpadding="1" </div>'
|| '<span style="font-size: 10pt; font-family: Arial"> </span> '
|| '<tr bgcolor=b4b4b4><td align="center"> <font size="3"> <b>'
|| 'Analysis</b></td><td align="center"><font size="3"> <b>'
|| 'Start Time</b></td><td align="center"><font size="3"> <b>'
|| 'End Time</b></td><td align="center"><font size="3"> <b>'
|| 'Run Duration (mins)</b></td><td align="center"><font size="3"> <b>'
|| 'Status</b></font></td></tr> ' || UTL_TCP.CRLF;
FOR curr_refresh IN (SELECT AN.ANALYSIS_ID,AN.NAME ANALYSIS_NAME,TO_CHAR(ARH.RUN_START_TIME,'DD/MM/YYYY HH:MI:SS') START_TIME,
TO_CHAR(ARH.RUN_END_TIME,'DD/MM/YYYY HH:MI:SS')END_TIME,
ROUND(((ARH.RUN_END_TIME-ARH.RUN_START_TIME)*24*60),2) RUN_TIME_SECS,ARH.JOB_STATUS STATUS
FROM
RUN_HISTORY ARH,ANALYSES AN
WHERE
AN.ANALYSIS_ID=ARH.ANALYSIS_ID
AND AN.CYCLE_IND_ID IN (1,3)
AND ARH.RUN_START_TIME>TO_DATE(SYSDATE-30)
AND ARH.JOB_NAME LIKE 'RHS_QU%'
AND AN.LOCATION_ID = loc_id.location_id
AND ARH.JOB_STATUS='Completed'
ORDER BY ARH.RUN_START_TIME DESC)
LOOP
l_analysis_report := l_analysis_report ||'<tr><td align="center">'|| curr_refresh.analysis_name
|| '</td><td align="center">' || curr_refresh.start_time || '</td><td align="center">'
|| curr_refresh.end_time || '</td><td align="center">'|| curr_refresh.RUN_TIME_SECS ||
'</td><td align="center">'|| curr_refresh.status ||
'</td> </tr>' || UTL_TCP.CRLF;
exit when length (l_analysis_report) > 32500;
END LOOP;
l_analysis_report := l_analysis_report || '</table><br><br>';
l_footer := UTL_TCP.CRLF ||'<b> Note: This is an auto generated email. Please do not reply to it. Contact the IT team for any further information.</b>'|| UTL_TCP.CRLF;
FOR curr_email IN (SELECT GLOBAL_NAME INSTANCE_NAME,
EU.EMAIL_USER_LAST_NAME last_name, EU.EMAIL_USER_FIRST_NAME ACNAME,
EU.EMAIL_USER_EMAIL_ID,loc.LOCATION_NAME LOC_NAME,
'[email protected]' MAIL_FROM
FROM
RHS_EMAIL_USER EU,LOCATIONS LOC,GLOBAL_NAME
WHERE EU.LOCATION_ID=LOC.LOCATION_ID
AND EU.LOCATION_ID=loc_id.location_id
) LOOP
cnxn := UTL_SMTP.open_connection('smtprelay.inc.com', 25);
UTL_SMTP.helo(cnxn, 'smtprelay.inc.com');
UTL_SMTP.mail(cnxn, '[email protected]');
UTL_SMTP.rcpt(cnxn, curr_email.EMAIL_USER_EMAIL_ID);
l_header := 'MIME-Version: 1.0'||'
To: ' || curr_email.last_name || ' <' || curr_email.EMAIL_USER_EMAIL_ID || '>
From: ' || curr_email.mail_from || '
Subject: Un-Adjusted Analysis Report for ' || curr_email.loc_name || ' Location from' || curr_email.instance_name || ' on ' || to_char(sysdate, 'DD-MON-YYYY') || '
Reply-To: [email protected]
Content-Type: text/html;' || UTL_TCP.CRLF || UTL_TCP.CRLF;
UTL_SMTP.data(cnxn, l_header || l_analysis_report || l_footer);
UTL_SMTP.quit(cnxn);
END LOOP;
END LOOP;
END PROC_STATUS_MAIL_UNADJ;
Error :-
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "SYS.UTL_SMTP", line 591
ORA-06512: at "SYS.UTL_SMTP", line 497
ORA-06512: at "SYS.UTL_SMTP", line 503
ORA-06512: at "RISK_HISTORY.PKG_RHS_EMAIL_NOTIFY", line 206
ORA-06512: at "RISK_HISTORY.PKG_RHS_EMAIL_NOTIFY", line 414
ORA-06512: at line 2Can you please let me know if there is any issue with code or any upgrade issue ?
Regards,
Sunny
Edited by: k_17 on Oct 13, 2011 12:07 PMHi Helios,
Many thanks for your reply.
I am able to figure out the issue. In the code we have
l_analysis_report := l_analysis_report ||'<tr><td align="center">'|| curr_refresh.analysis_name
|| '</td><td align="center">' || curr_refresh.start_time || '</td><td align="center">'
|| curr_refresh.end_time || '</td><td align="center">'|| curr_refresh.RUN_TIME_SECS ||
'</td><td align="center">'|| curr_refresh.status ||
'</td> </tr>' || UTL_TCP.CRLF;
exit when length (l_analysis_report) > 32500;where "l_analysis_report VARCHAR2(32767);"
The issue is report has more characters, and when executing it throws the error " ORA-06502: PL/SQL: numeric or value error: character string buffer too small ".
Can you please let me know how to have more characters/data in the report. Will CLOB help if yes, please let me know how to use it.
Kindly suggest some options.
Regards,
Sunny -
Checking for a process using vbscript
Hi all,
Need help with a script. I have a script that is uninstalling trend micros and then installing mcafee. The install leaves up two cmd prompts and as it installs the cmd prompts go away. The second command prompt goes away after about 30 minutes or so. Need
a way to track when it completes so I can prompt the user that the script is complete and then write the machine name to a file that it has completed. Here is the code below
ON ERROR RESUME NEXT
Dim file
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FilesystemObject")
set objShell = Wscript.CreateObject("WScript.Shell")
'VPN Check
If objFSO.FolderExists("Some Folder") then
objshell.Popup "YOU ARE CURRENTLY ON VPN/SMITH AND NEPHEW NETWORK." & vbCrLf & "PRESS OK TO CONTINUE.", 60, "IT INFORMATION UPDATE", vbOKOnly
Else
objShell.Popup "UNABLE TO LAUNCH SCRIPT" & vbCrLf & "YOU ARE NOT ON THE VPN/SMITH AND NEPHEW NETWORK." & vbCrLf & VbCrLf & "PLEASE GET ON IT REMOTE ACCESS(FULL) AND RUN THE ATTACHMENT AGAIN.", 60, "IT INFORMATION
UPDATE", vbOKOnly
Wscript.Quit
End If
Set file = CreateObject("Scripting.FilesystemObject")
file.DeleteFile("C:\Programdata\Microsoft\Windows\Start Menu\Programs\Startup\Message.vbs")
'GPUpdate
WshShell.Run "%comspec% /c gpupdate /force"
WScript.Sleep(90000)
'Uninstall Trend Micro
If objFSO.FileExists("C:\Program Files (x86)\Microsoft Office\Office14\Winword.exe") Then
WshShell.Run """C:\Program Files (x86)\Trend Micro\OfficeScan Client\ntrmv.exe"" -980223" ,0,True
ElseIf objFSO.FileExists("C:\Program Files\Microsoft Office\Office14\Winword.exe") Then
WshShell.Run """C:\Program Files\Trend Micro\OfficeScan Client\ntrmv.exe"" -980223" ,0,True
Else WScript.Echo "having trouble"
End If
'Install McAfee
If objFSO.FileExists("C:\Program Files (x86)\Microsoft Office\Office14\Winword.exe") Then
WshShell.Run "%comspec% /c E: & cd ""\McAfee\Agent\v4.5.0.1852\"" & cscript Appsetup(x64).vbs"
WshShell.Run "%comspec% /c E: & cd ""\McAfee\VSE&ASE\v8.8 with Patch1\"" & cscript Appsetup(x64).vbs"
ElseIf objFSO.FileExists("C:\Program Files\Microsoft Office\Office14\Winword.exe") Then
WshShell.Run "%comspec% /c E: & cd ""\McAfee\Agent\v4.5.0.1852\"" & cscript Appsetup(x86).vbs"
WshShell.Run "%comspec% /c E: & cd ""\McAfee\VSE&ASE\v8.8 with Patch1\"" & cscript Appsetup(x86).vbs"
Else WScript.Echo "Trouble Installing McAfee! Please call SNBio IT at and select Option 2 for support."
WScript.Quit
End If
WScript.Quit
ChristopherOk... so far I have this code that is kind of working but won't exit the loop even though the process is dead. Any help would be appreciated. Code below. Thanks in advance.
set objWMIService = GetObject ("winmgmts:")
foundProc = False
procName = "cmd.exe"
procNameFriend = "Command Prompt"
for each Process in objWMIService.InstancesOf("Win32_Process")
If StrComp (Process.Name,procName,vbTextCompare) = 0 then
foundProc = true
End If
Next
Do while foundProc=True
If foundProc=True Then
WScript.Echo "Process Found"
WScript.Sleep (10000)
ElseIf foundProc=False Then
Exit Do
WScript.Echo "Process is done"
WScript.Quit
End If
Loop
'WScript.Echo "Process is done"
Christopher -
Hello,
I have created two customer exit variables, although I'm not an ABAP expert. Both are calculated based on two optional variables selected by the user.
When running my query I get the message "Warning Value '' is too long for variable ZPERSTRT". I suppose that really means the value is empty while a value was expected. The type of this variable is 0DATE.
I try checking the code to examine how the value can be empty, and that results in a few questions some of you probably can answer.
Unfortunately, for complex reasons I have to program the customer exit variables in the development system, while testing them in the test system where I don't have access to the ABAP editor.
QUESTION 1
When finding the values of the other variables, I must be prepared to find them without a value. How can I know if they have a value or not? I've tried with the following code, which I suspect is not working quite as expected:
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam = 'ZCALWINT'.
IF loc_var_range-low <> ''.
l_week0 = loc_var_range-low.
l_flag = 1.
ENDIF.
ENDLOOP.
I later use l_flag to check if a value was found or not.
QUESTION 2
How is type conversion done in a statement like
date = string + 1
If string has the value "20071031", will 1 be added as a string (resulting in "200710311" which is then somehow converted to a date), like a number (resulting in "20071032" which is then somehow converted to a date) or like a date (resulting in "20071101")?
QUESTION 3
More type conversion. Would it be ok to concatenate year, month and day into a date variable, or should I always concatenate into a string which can then be converted to a date afterwards?
QUESTION 4
If the variable I want to read has an interval and not only a single value, is the only way to see this by checking the -high value? If this one has a value it is an interval, if not it is a single value? Or can I be sure the -opt value will be 'BT' if it's an interval?
Thanks and regards,
ChristofferAnyone?
I'll award 10 points to the best overall answer and 6 points to answers which are first or best on one of the four questions.
Regards,
Christoffer -
Main/subVI control confusion
hello one and all,
i am a little confused on the best way to approach this. i have a main and sub VI. the main VI is the main VI and the sub VI has a complex settling routine and after all the little parameters have settled out, it quits its while loop and returns control back to the main which collects, averages, and manipulates the settled data.
ok, so i want the stop button on the main VI to stop the sub VI while loop in mid stream if need be; to gracefully exit the program. so i experimented with Notifiers, which worked well with the latter. but then i need to pass input parameters changes from the main into the sub and then when the sub is finished settling, pass output parameter changes from the sub back into the main. i tried Notifiers on that and it looks ok with the input parameters but gets pretty damn messy with the output parameters.
so what is the best way to approach and achieve input and output parameter changes while gracefully aborting nicely? thank you in advance and have a great day. lucas p.s. i am using labview 2010 x64 bit under win7.Take a look at the 'message handler' design pattern.
I'd use queues instead of notifiers, as passing a bunch of parameters would override each other when using notifiers.
Then use a 'message'-type-def-cluster. First part is the message such as SetParamA (use an enum or string), the second part is any data you want to send along such as parameter values (use string or variant + FlattenToString/UnflattenFromString or the variant functions). I did demonstrate this using events here.
You will need to code your message handler ('SubVi') to check from time-to-time if a new message is available. This is best modelled as a state-machine, where you either have an 'idle' state in which you wait for the next message or you check for new messages in each iteration and perform 'normal' states when the Dequeue gives you a timeout, otherwise first handle the message.
Felix
www.aescusoft.de
My latest community nugget on producer/consumer design
My current blog: A journey through uml
Maybe you are looking for
-
HotSpot Virtual Machine Error : 11 Error ID : 4F530E43505002EF; RedHat ES3
All we are using tomcat 4.1.30 with apache 2.0.49(and mod_jk 1.2.5) for our application. Our OS is as follows, Red Hat Enterprise Linux ES release 3 (Taroon) Kernel 2.4.21-4.0.1.EL on an i686 We are experiencing JVM crashes wherein the VM crashes wit
-
How to release table locks?
I was running Data Services (4.0 SP2) to load data into Hana (1.0 SP2 patch 20) using the Bulk load option. Apparently, the DS process hung and now the table I was writing to is locked although the DS Job is dead. How do you release the table lock wi
-
Hi Guru's, I have created a processorder in T-code COR1..now i want to cancel the confirmed process order..plz tell me the process. Thanks & regards cherukuri
-
What's wrong with adobe this days?
Guys, I'm just having lot of problems but A LOT, there is always a problem when I have to edit something... I'll explain it to you... First of all I can't edit my flles from dxtory x264 you have to pay like 300 pounds well, there is a thread already
-
Problem with CMR using MySQL under JBoss with xDoclet.
My problem is that I'm trying to create a CMR between to EJB. The server don't show error messages but when I look at the database I realise that the foreign key is not created. I have test if telling xDoclet to create the field but if I do this, the