Prompting for user input in nested select statements
I recently rewrote a query to use a nested select statement instead of specifying every SELECT field on the GROUP BY line. Here's the query which works perfectly with hard-coded values of '030', '01/01/11', and '12/31/11'.
SELECT T0.[CardName] AS Customer, T0.[CardCode] as 'Cust ID', T0.[Phone1] as Phone, T0.[CntctPrsn] as 'Contact Person', T0.[Address], T0.[City], T0.[State1] as State, T0.[ZipCode] as 'Zip Code', T0.[Country], T1.[TotalSales]
FROM OCRD T0
INNER JOIN
(SELECT I.[CardCode] AS CardCode, SUM(I.[DocTotal]) AS TotalSales
FROM OINV I
WHERE left (I.[CardCode], 3) = '030' AND (I.[DocDate] >= '01/01/11' AND I.[DocDate] <= '12/31/11')
GROUP BY I.[CardCode]) T1
ON T0.[CardCode] = T1.[CardCode]
ORDER BY T0.[CardName]
When I try to prompt for the left 3 characters of the CardCode (or the dates), ie.
WHERE left (I.[CardCode], 3) = [%0] AND (I.[DocDate] >= '01/01/11' AND I.[DocDate] <= '12/31/11')
I get an error "Column 'OCRD.CardName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause".
It's like putting a user variable in the inner SELECT made it part of the outer SELECT which is exactly what I was trying to avoid by re-writing this query with the inner SELECT.
Can anyone explain what SQL Server is doing here and how to fix it?
Thanks Gordon. That's how I originally wrote the query and it works fine. But I was disturbed that I had to GROUP BY every field in my SELECT statement when I really only wanted to group by CardCode. So I did some research and came up with this where the inner select still groups by only CardCode and still takes user input. I don't really understand why you need the commented SELECT statements in the SET lines, but you do. Something about using real table fields for variables.
DECLARE @startDate datetime
DECLARE @endDate datetime
DECLARE @rep varchar(10)
SET @rep /* SELECT T0.[CardCode] FROM ORDR T0 WHERE T0.[CardCode] */ = '[%0]'
SET @startDate /* SELECT T0.[DocDate] FROM OINV T0 WHERE T0.[DocDate] */ = '[%1]'
SET @endDate /* SELECT T0.[DocDate] FROM OINV T0 WHERE T0.[DocDate] */ = '[%2]'
SELECT T0.[CardName] AS Customer, T0.[CardCode] as 'Cust ID', T0.[Phone1] as Phone, T0.[CntctPrsn] as 'Contact Person', T0.[Address], T0.[City], T0.[State1] as State, T0.[ZipCode] as 'Zip Code', T0.[Country], T1.[TotalSales]
FROM OCRD T0
INNER JOIN
(SELECT I.[CardCode] AS CardCode, SUM(I.[DocTotal]) AS TotalSales
FROM OINV I
WHERE left (I.[CardCode], 3) = @rep AND (I.[DocDate] >= @startDate AND I.[DocDate] <= @endDate)
GROUP BY I.[CardCode]) T1
ON T0.[CardCode] = T1.[CardCode]
ORDER BY T0.[CardName]
FOR BROWSE
Similar Messages
-
How to prompt for user input in Forms
How do I prompt for user input in Forms?
I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither?
If the user chooses to input the value I want to update a set of database fields with the value.
I have thought about showing a view where the value may be entered into a field displayed on that view. The value will be assigned to the variable by the user clicking a command button. The question I have in this case though, is whether, after the command button is clicked, control will be passed back to the code that called the view in the first place?Desgordon,
This can be accomplished by displaying your message to the user using an Alert. I use 3 different Alerts (Note, Caution and Stop) in my forms and they are inherited from a central source file (such as an Object Library or a Template Form) so they can be used by all of my Forms. You can set the text of the Alert using the SET_ALERT_PROPERTY() built-in and capture what button the user presses with the SHOW_ALERT() built-in. Additionally, if you need more than one button to be displayed in an alert, you use the SET_ALERT_BUTTON_PROPERTY() built-in to rename the default button or to add up to a total of three buttons in the alert. Here's an example:
DECLARE
Alert_ID ALERT;
v_AlertType VARCHAR2(10) := 'CAUTION';
v_AlertTitle VARCHAR2(25);
v_AlertText VARCHAR2(150);
n_AlertButton NUMBER;
BEGIN
v_AlertTitle := 'Title of Alert';
v_AlertText := 'This is message to the user.';
/* Code leading up to the decision point. */
alert_id := FIND_ALERT(v_AlertType);
/* Note: I only set the Label of Button 2 because the default button 1 label is 'OK' */
SET_ALERT_BUTTON_PROPERTY(v_AlertType, ALERT_BUTTON2, LABEL, 'Cancel');
SET_ALERT_PROPERTY(Alert_ID, v_AlertTitle, v_AlertText);
n_AlertButton := SHOW_ALERT(Alert_ID);
/* Now I can test the value of n_AlertButton for 1 or 2 to find out what button the user selected. */
IF ( n_AlertButton = 1 ) THEN
/* Do something, because the user selected 'OK' */
ELSE
/* It is assumed at this point that the user selected 'CANCEL' */
/* Stop processing any further. */
RAISE form_trigger_error;
END IF;
END:Hope this helps.
Craig...
-- If my response or the response of another answers your question, please mark the response accordingly. Thanks! -
"catching" a prompt for user input and answering it through zenity?
I'm trying to write a script (or multiple scripts) that will allow me to use command-line only applications via user defined actions in my file manager without having to open a terminal. Now I realize this basic functionality is already available, but as it stands I am unable to respond to command-line prompts for user input without opening a terminal. Is it possible to write a shell script that would act as a wrapper and allow me to use zenity (or another popup program) to respond to such queries?
For example if I used a command-line program that prompted me for a password, could I "catch" that prompt with a shell script and answer it through another program, such as zenity?
Last edited by falconheart (2011-01-16 22:37:25)The easier way to do this is to collect the info with zenity first, then pass it on the command line. If the program insists on prompting, then you could try feeding it the info with redirection if it accepts it from stdin. For example
command < info.txt
where info.txt is a temp file created by your script which contains whatever you want entered into the prompts. This will work in some cases. -
How to prompt for user input in PL/SQL
How do I prompt for user input in PL/SQL?
I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither?
If the user chooses to input the value I want to update a set of database fields with the value.
I have thought about showing a view where the value may be entered into a field displayed on that view. The value will be assigned to the variable by the user clicking a command button. The question I have in this case though, is whether, after the command button is clicked, control will be passed back to the code that called the view in the first place?
Edited by: desgordon on Sep 3, 2008 10:33 AMdesgordon wrote:
How do I prompt for user input in PL/SQL?
I am writing a piece of code where the user may choose, by clicking either of three buttons on an alert, to have the system assign a value to a variable, to input a value or to do neither?OK, you're doing that in Forms...
>
If the user chooses to input the value I want to update a set of database fields with the value.Write PL/SQL procedure for this purpose...
>
I have thought about showing a view where the value may be entered into a field displayed on that view. The value will be assigned to the variable by the user clicking a command button. The question I have in this case though, is whether, after the command button is clicked, control will be passed back to the code that called the view in the first place?Not clear what you mean with view?
But if you call your procedure in that button then yes 'control will be passed back to the code'...
Cheers!
Edited by: Faust on Sep 3, 2008 7:57 PM
Too slow... -
Prompt For User Input in SQL Developer
I am using the '&' in a very basic SQL select script, but I do not get a prompt for my input. However, i have used the '&' in update scripts and it does prompt me.
For example:
select DCC_DESCRIPTION
from S_TBLDTMINOR
where DCC_DTMINOR = &Minor;
Gives an ORA-01008 error (not all variables bound).
If it's a varchar field and I use '&Minor' - it executes with no error, but does not prompt for data. Please note: this script works when it's run in SQL*Plus, but not in SQL Developer.
If I execute:
update S_TBLDTMINOR
set DCC_DESCRIPTION = 'Mark & Wilson'
where DCC_DTMINOR = 'AAA';
It does prompt me for a value (but I do not want it to).
So I know prompting works in SQL Developer, but it does not work in select statements.
Is this a configuration setting I can change in SQL Developer? I know I can use the escape in the update statement to avoid the prompt, but I'm not concerned with that. I'm trying to get the prompting to work in the select statement.
Edited by: user12289057 on Feb 23, 2012 11:17 AMHi user12289057,
1/Not sure what your testcase is (including table definition), I was trying to reproduce with:
select * from dual where dummy = '&myin'
2/Try
undefine Minor
to ensure Minor is not already set.
3/Minor may need to be quoted if it is a string.
Short blog post on substitution and bind variables.
http://totierne.blogspot.com/2010/04/substitution-and-bind-variables.html
-Turloch
SQLDeveloper team. -
How to force sql developer to prompt for user input for every execution ?
Hi Folks,
Environment: Oracle 11g (on Windows 7)
SQL Developer: *3.1.07*
I am executing a PL/SQL code off Sql Developer. The code uses substitution variables to prompt user for input. However,I am only prompted for the user input for the very first run of the code. For the subsequent executions, the code simply picks up the user input from the very first run. This behavior persists for all subsequent runs of the code.
I have executed the same piece of code from SQL*PLUS and the behavior seems normal (i.e. I am prompted for fresh input for every execution)
How can flush out the old user input so I can be prompted for new user input for every run of the code in sql developer?
Thanks in advance
rogers42Hi Rogers42,
1/try
undefine
undefine fred
select '&&fred' from dual;
[run this multiple times]
[prompts gere]
old:select '&&fred' from dual
new:select 'a' from dual
'A'
a
[prompts here]
old:select '&&fred' from dual
new:select 'b' from dual
'B'
b
2/try
exit (requires recent version of sql developer: tools->preferences->Database->worksheet->Re-initialize on script exit command)
select '&&fred' from dual;
exit
run this multiple times
[prompts here]
old:select '&&fred' from dual
new:select 'x' from dual
'X'
x
Commit
[prompts here]
old:select '&&fred' from dual
new:select 'y' from dual
'Y'
y
Commit
3/use &fred instead of &&fred
For background see
http://totierne.blogspot.co.uk/2010/04/substitution-and-bind-variables.html
-Turloch
SQLDeveloper team -
Increasing max # of inputs on prompt for user input
Hi
I would like to increase the number of inputs beyond 10 available on the prompt user for input function. At the moment I am using 9 of the 10 available inputs each running a subVI from a case structure. I seem to be limited to 10 inputs using the prompt user for input function so is there another way of prompting the user to select from >10 inputs preferably 20.
Thanks for any help
Chris
Solved!
Go to Solution.
Attachments:
WASP dialog.vi 57 KBYou can always write you own dialog with as many selections as you like.
Right-click the express VI and "open front panel" This will convert it to a VI that you can edit in any way you want. save it under a new name.
You might even want to add some validation code, e.g. to make sure that no more than 2 boxes are checked.
LabVIEW Champion . Do more with less code and in less time . -
Hi,
1) Want to prompt user for username & password
2) connect to oracle
3) want to use substring function on username entered by user
3) user of substring output in procedure
Performed as shown below but not working,
PROMPT Enter username and password.
PROMPT
user:=&username;
pass:=&passowrd;
tns:=&tnsname;
conn user/pass@tns
PROMPT
PROMPT
set serveroutput on
DECLARE
variable1;
variable2;
varibale3;
var:=substring(user,1,4);
BEGIN
var.package_name.procedure_name(cur);
FETCH cur INTO variable1,variable2,varibale3;
dbms_output.put_line('XYZ');
END;
Edited by: user640001 on Feb 28, 2012 11:27 PMtrying to run as below but getting error for 'var'
DECLARE
var varchar2(20):=substr('&un',1,4);
variable1 varchar2(20);
cur var.package_name.Cursor;
BEGIN
var.package_name.procedure_name(cur);
FETCH cur INTO variable1;
dbms_output.put_line(variable1);
END;
cur var.package_name.Cursor;
ERROR at line 16:
ORA-06550: line 16, column 7:
PLS-00487: Invalid reference to variable 'VAR'
ORA-06550: line 16, column 7: -
Is it possible to nest SELECT statements?
Greetings community,
Another newbie’s question it is. Looking tutorials and some posts here I’ve been advised not to pull entire table through the local network, and torture client machines’ processors and memory. It’s been said that better solution is to
pull just one part of the table.
So, imagine this: you want to make a part of your app that would allow your user to view list of orders. So you put one data grid view on the form, pull last 20 headers from the table into it and leave to user to choose one to be opened
in another form. If user doesn’t find header they want, they press page up for example and previous 20 headers are loaded into data grid view. Of course, user could filter headers list by customer, or by distribution lane (having all customers residing in
one part of the town), or whatever more, but let’s not complicate things at this moment, because I’m practically in the beginning.
I’m trying to make a stored procedure that would load penultimate 20 headers when user presses page up. So, not knowing any better, I created table variable that has the same structure as Orders table with one difference: OrderID column,
which is identity (auto incremented) in Orders table, here is simply defined as bigint not null. Community member Visakh16 warned me few months ago it’s the bad practice to put self-incrementing columns in table variables.
At this moment there’s a query on my screen, which waits to become store procedure. After boring part with table variable definition, it goes like this:
INSERT INTO @OrdersTemp SELECT TOP 40 * FROM dbo.Orders ORDER BY OrderID DESC
SELECT TOP 20 * FROM @OrdersTemp ORDER BY OrderID ASC
To put that simply, I pull last 40 headers into table variable, and then pull first 20 from there. This thing works, and I just have to replace 40 with parameter, for every page up or down.
Now I have few questions.
-Is there some better way (considering performance) to achieve that? Here is the place where I wanted to ask the question from the title of the post. I don’t know much about T-SQL, and I’m not sure about the proper syntax to nest SELECT
statements, if something like that is even possible
-Is there any better way (some built-in function) to find about the count of the rows in one table than
SELECT COUNT(OrdersID) FROM dbo.Orders
Thanks for any suggestions.Hi Erland,
Sorry for the very late reply, but I said that I would start another thread when I find more free time to dedicate it to this, so I didn’t really expected you to reply anymore. I didn’t really check here for more than a week, and I glanced
at mail accidentally.
As for the negative result I got, its measurement unit is microsecond, so it doesn’t go out of margins you had experienced.
As for the number of cores, you got me surprised there. I use express edition of SQL server. Last time I checked was SQL server 2012 express, and in specifications it said that express edition is limited to 1 processor core, 1GB of RAM
and creates up to 10GB database file. I don’t believe they changed any of those specifications. It was generous enough when they doubled size of DB file few editions ago. Still, it appears that “one processor core for express edition” statement has some gray
areas in it.
However, at this moment I’m just learning, and I just wanted some way to test how efficient my queries are. I don’t have a real biz problem to solve. I don’t expect that any real performance problem should rise in years of everyday work
of populating database. What I expect is performance impact when it comes to creating reports, but after all, I don’t think that my boss would create reports by himself. I believe that creating reports would be my task, and I will be doing it after hours,
being the only user at the moment. Or maybe I could make de-normalized copy of database that would be populated after hours to make it possible for my boss to get his reports faster by himself, as I’ve heard that was the way of making BI in older non-express
editions.
So, I do suggest that we finally close this thread for sake of other readers. I’ll start another one with this subject when I find the time to do it.
Again, thanks for being with me along this journey. -
Need help with Java app for user input 5 numbers, remove dups, etc.
I'm new to Java (only a few weeks under my belt) and struggling with an application. The project is to write an app that inputs 5 numbers between 10 and 100, not allowing duplicates, and displaying each correct number entered, using the smallest possible array to solve the problem. Output example:
Please enter a number: 45
Number stored.
45
Please enter a number: 54
Number stored.
45 54
Please enter a number: 33
Number stored.
45 54 33
etc.
I've been working on this project for days, re-read the book chapter multiple times (unfortunately, the book doesn't have this type of problem as an example to steer you in the relatively general direction) and am proud that I've gotten this far. My problems are 1) I can only get one item number to input rather than a running list of the 5 values, 2) I can't figure out how to check for duplicate numbers. Any help is appreciated.
My code is as follows:
import java.util.Scanner; // program uses class Scanner
public class Array
public static void main( String args[] )
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in);
// declare variables
int array[] = new int[ 5 ]; // declare array named array
int inputNumbers = 0; // numbers entered
while( inputNumbers < array.length )
// prompt for user to input a number
System.out.print( "Please enter a number: " );
int numberInput = input.nextInt();
// validate the input
if (numberInput >=10 && numberInput <=100)
System.out.println("Number stored.");
else
System.out.println("Invalid number. Please enter a number within range.");
// checks to see if this number already exists
boolean number = false;
// display array values
for ( int counter = 0; counter < array.length; counter++ )
array[ counter ] = numberInput;
// display array values
System.out.printf( "%d\n", array[ inputNumbers ] );
// increment number of entered numbers
inputNumbers++;
} // end close ArrayYikes, there is a much better way to go about this that is probably within what you have already learned, but since you are a student and this is how you started, let's just concentrate on fixing what you got.
First, as already noted by another poster, your formatting is really bad. Formatting is really important because it makes the code much more readable for you and anyone who comes along to help you or use your code. And I second that posters comment that brackets should always be used, especially for beginner programmers. Unfortunately beginner programmers often get stuck thinking that less lines of code equals better program, this is not true; even though better programmers often use far less lines of code.
// validate the input
if (numberInput >=10 && numberInput <=100)
System.out.println("Number stored.");
else
System.out.println("Invalid number. Please enter a number within range."); Note the above as you have it.
// validate the input
if (numberInput >=10 && numberInput <=100)
System.out.println("Number stored.");
else
System.out.println("Invalid number. Please enter a number within range."); Note how much more readable just correct indentation makes.
// validate the input
if (numberInput >=10 && numberInput <=100) {
System.out.println("Number stored.");
else {
System.out.println("Invalid number. Please enter a number within range.");
} Note how it should be coded for a beginner coder.
Now that it is readable, exam your code and think about what you are doing here. Do you really want to print "Number Stored" before you checked to ensure it is not a dupe? That could lead to some really confused and frustrated users, and since the main user of your program will be your teacher, that could be unhealthy for your GPA.
Since I am not here to do your homework for you, I will just give you some advice, you only need one if statement to do this correctly, you must drop the else and fix the if. I tell you this, because as a former educator i know the first thing running through beginners minds in this situation is to just make the if statement empty, but this is a big no no and even if you do trick it into working your teacher will not be fooled nor impressed and again your GPA will suffer.
As for the rest, you do need a for loop inside your while loop, but not where or how you have it. Inside the while loop the for loop should be used for checking for dupes, not for overwriting every entry in the array as you currently have it set up to do. And certainly not for printing every element of the array each time a new element is added as your comments lead me to suspect you were trying to do, that would get real annoying really fast again resulting in abuse of your GPA. Printing the array should be in its own for loop after the while loop, or even better in its own method.
As for how to check for dupes, well, you obviously at least somewhat understand loops and if statements, thus you have all the tools needed, so where is the problem?
JSG -
Nested select statements.
Hi, I am writing a piece of code in which i use nested select statements for 4 tables to retrieve one column's data (ie: POSNR). But when i execute it, it takes way too long to get the data. I'm quite new to ABAP so very in need of your help. Thanks
REPORT z_impos_test.
TABLES: coss, "CO Object: Cost Totals for Internal Postings
afvc, "Operation within an order
prps, "WBS (Work Breakdown Structure) Element Master Data
imzo. "Table: CO Object - Capital Investment Prog.Pos.
TYPES: BEGIN OF st_impos,
objnr TYPE coss-objnr,
gjahr TYPE coss-gjahr,
kstar type coss-kstar,
projn type afvc-projn,
pspnr type prps-pspnr,
posnr type imzo-posnr,
END OF st_impos.
data: year TYPE coss-gjahr value '2007'.
DATA: t_output TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
st_output TYPE st_impos,
t_output2 TYPE STANDARD TABLE OF st_impos WITH HEADER LINE,
st_output2 TYPE st_impos.
SELECT objnr gjahr kstar FROM coss
INTO CORRESPONDING FIELDS OF st_output
WHERE ( objnr LIKE 'NV%' OR
objnr LIKE 'PR%' ) AND
gjahr = year.
SELECT SINGLE projn from afvc into CORRESPONDING FIELDS OF st_output
WHERE objnr = st_output-objnr.
APPEND st_output to t_output.
ENDSELECT.
SORT t_output BY objnr.
DELETE ADJACENT DUPLICATES FROM t_output.
LOOP AT t_output into st_output.
SELECT objnr pspnr
INTO CORRESPONDING FIELDS OF st_output2
FROM prps
WHERE objnr = st_output-objnr
AND pspnr = st_output-pspnr.
SELECT SINGLE posnr from imzo into CORRESPONDING FIELDS OF st_output2
WHERE objnr = st_output2-objnr.
APPEND st_output2 to t_output2.
ENDSELECT.
ENDLOOP.
LOOP AT t_output2 to st_output2.
WRITE: st_output2-posnr.
ENDLOOP.
Edited by: Jacie Johns on Apr 23, 2009 11:26 PMHI John,
Try to avoid INTO CORRESPONDING FIELDS in SELECT statement.
As you are not using PSPNR and POSNR fields in the first SELECT statement. If you remove these fields, in structure, INTO CORRESPONDING FIELDS can be avoided. Create a separate structure with the fields that are required for T_OUTPUT table (i.e. create another structure with only first 4 fields, as T_OUTPUT1.
And as mentioned in your code,
WHERE objnr = st_output-objnr
AND pspnr = st_output-pspnr
in select statement, ST_OUTPUT-PSPNR value is not fetched in the previous select statements.
Create Another structure with fields OBJNR, PSPNR, POSNR for table T_OUTPUT2 to store the data from tables, PRPS and IMZO.
Use JOINS and FOR ALL ENTRIES to fetch the desired data.
The sample code is as follows:
===
TYPES: BEGIN OF ty_output1,
objnr TYPE coss-objnr,
gjahr TYPE coss-gjahr,
kstar type coss-kstar,
projn type afvc-projn,
END OF ty_output1,
BEGIN OF ty_output2,
objnr TYPE coss-objnr,
pspnr type prps-pspnr,
posnr type imzo-posnr,
END OF ty_output2,
BEGIN OF ty_output3,
objnr TYPE coss-objnr,
gjahr TYPE coss-gjahr,
kstar type coss-kstar,
projn type afvc-projn,
pspnr type prps-pspnr,
posnr type imzo-posnr,
END OF ty_output3.
data: year TYPE coss-gjahr value '2007'.
DATA:
wa_output1 TYPE ty_output1,
wa_output2 TYPE ty_output2,
wa_output3 TYPE ty_output3,
t_output1 TYPE STANDARD TABLE OF ty_output1 ,
t_output2 TYPE STANDARD TABLE OF ty_output2 ,
t_output3 TYPE STANDARD TABLE OF ty_output3..
SELECT cobjnr cgjahr ckstar aprojn FROM coss as c
INNER JOIN afvc as A on aobjnr = cobjnr
INTO table t_output1
WHERE ( c~objnr like 'NV%' or
c~objnr like 'PR%' ) and
c~gjahr = year.
SELECT pobjnr ppspnr i~posnr FROM prps as P
INNER JOIN imzo AS I on pobjnr = iobjnr
INTO TABLE t_output2
for all entries in table T_OUTPUT1
WHERE p~objnr = t_output1-objnr.
SORT : t_output1 BY objnr,
t_output2 BY objnr.
DELETE ADJACENT DUPLICATES FROM : t_output1 COMPARING objnr,
t_output2 COMPARING objnr.
LOOP AT t_output1 INTO wa_output1
READ TABLE t_output2 INTO wa_output2 WITH KEY objnr - wa_output1-objnr BINARY SEARCH.
if sy-subrc = 0.
MOVE <wa_output1 fiels> and <wa_output2 fields> to WA_OUTPUT3.
append wa_output3 to T_OUTPUT3.
endif.
ENDLOOP.
Hope this will solve your problem.
Regards,
Sai Prasad -
How do you keep a VI running while waiting for user input?
I have a VI that:
1. The user enters set points.
2. The user starts the VI and the VI sends the set points to an external process via a serial interface.
3. The VI stops running.
4 The user waits for the external process to complete.
5. Repeat sequence. Go to Step 1.
This works well except for one small problem. Starting the VI in step 2 causes an external micro controller to reset. During the reset it will ignore set point commands. To get around this problem a delay has been added between when the VI opens the serial port and when the VI sends the set points to the external process Is it possible to keep a VI running continuously in this type of application, thereby eliminating the start up and shut down of the serial interface?
If yes, how do you keep a VI running while waiting for user input?
HowardThe ones for the event structure specifically. I'm posting from my phone. Look at the basic ones for user input. even a simple while loop with a boolean and a case statement would work.
-
How to make Flash to wait for user input
Hi,
I found this PHP script, then I made some changes to make it
FEED the Flash user interface with online user input.
The main concept of this script is WAITING for user input, so
it shows the messages and then go to next line and so on.
The user input go to directly to TEXT file which writes in
lines, each line has a unique id = (mag_id).
There "get_msge.php" which works as the middleware between
FLASH and messages text file.
The problem, its doesn’t show any data while there are
data in the text file.
Help here please, best regards.
This is the link of
problem illustartion
AS is:
// create an object to store the variables
varReceiver = new LoadVars();
// load the variables from the text file
varReceiver.load("get_msg.php?file_id=1&msg_id=1",
"POST");
// trigger something - when the variables finish loading
varReceiver.onLoad = function(){
//the variables have finished loading
if (this.msg_id == 1) {
_root.xmsg1_swf.text = this.msg;
_root.xmsg1_ch.text = this.msg;
gotoAndPlay("line2");
} else {WAIT }
PHP is:
<?php
//get these values from the FLASH
$file_id_swf = $_POST ['file_id'];
$file_name = "messages/messages".$file_id_swf.".txt";
$msg_id_swf = $_POST ['msg_id'];
// [0] ."||".[1] ."||".[2] ."||". [3] ."||".[4]."||". [5].
//$msg_id."||".date."||".time."||".$from."||".$to."||".$msg.
$fp = fopen ($file_name, 'rb');
while (!feof ($fp))
$msg_txt = fgets ($fp, 1024);
$line = explode ("||", $msg_txt);
$msg_id = $line[0];
$from = $line[3];
$to = $line[4];
$msg = utf8_encode ($line[5]);
if ($msg_id == $msg_id_swf)
echo
"msg_id=".$msg_id."&from=".$from."&to=".$to."&msg=".$msg;
}//while
fclose ($fp);
?>Well, given the things that you've written, I don't think it
could. There technically isn't any code in flash that lets it
"wait." In order to "wait," you must run the script over again
until some condition is met.
However, your code does look accurate. Why do you need to
wait? The onLoad function will be invoked WHEN something is loaded.
So, I don't see the reason for the "waiting."
In addition to that, I would like to say that using text
files isn't that great with flash. I have done this before and
noticed several problems with using text files. The biggest problem
is that the text files are cached after being loaded. Every time
you re-load it again, you will get what you got the first time
until you reset your cache (ie. close your browser). I suggest
using MySQL. (Just my thought.) -
Asking for user input in the middle of a function
Here's my issue.
I need to launch and input window in the middle of a function for user input. Before I can continue through the function I need a response back from the user first. Psuedo code below:
function
function begins
pop up window is launched to ask for user input
function continues after users submits input
user input from pop up window is used in function return value
Let me know if you need more clarification but this is essentially what I'm attempting to do.The way actionScript works it isn’t really designed to work that way
Is there any reason why you have to only use one function as you have written
I think you really do need to split up your code into sections that a, set up the pop-up with event listeners waiting for the input to be completed, trigger the pop up with user input, then have a handler function that then interprets the results of the user action.
Trying to force the system into a closed loop while waiting will be a bad idea.
By using a pop-up or an alert window that is set to be modal, you are effectively stopping your application doing anything else until the user input has been completed, but still not locking the app into a closed loop. Imagine what would happen if you did put the system into a closed loop, the mouse movement wouldn’t be updated, the screen wouldn’t refresh and the system wouldn’t be able to handle your user input. the reason for using async model is you are able to let the system still do all its background task (move the mouse, give inputs focus, keep the screen drawn etc) but still tell a part of your app to ‘wait for input’ before carrying on it execution of your logic
Do you come from another programming language? Maybe one that uses less of an OOP approach? I only ask, as the method you are describing is much more like how I had to program when I worked on computers years ago as an assembly programmer.
In actionscript and most other modern languages and Oss you don’t have total control of the system and cant lock it into an action as you describe.
You need to have an asynchronous approach to situations like you describe and let the system run in the back ground while you are waiting for input (or date from a server for that matter)
Please excuse me if I am telling you things you already know.
What exactly is your use case for this? Maybe if we knew exactly what you are working on I might be able to offer a solution that would make sense for your particular situation.
Hope all is going well and please feel free to contact me if you are stuck -
ADF security - prompt for user id and password again on page forward
Hi,
I am working with ADF using JDeveloper 10.1.3 with Business Components and ADF Faces.
I have a Search page and a List page.
Both pages are based on the same view within the same application module.
The Search page is using the default Find and Execute Operations.
The Execute button has an action that navigate to the List screen.
faces-config.xml
<navigation-rule>
<from-view-id>/jspx/search.jspx</from-view-id>
<navigation-case>
<from-outcome>search</from-outcome>
<to-view-id>/jspx/list.jspx</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/jspx/list.jspx</from-view-id>
<navigation-case>
<from-outcome>find</from-outcome>
<to-view-id>/jspx/search.jspx</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
Security (Roles and Users) is based on the jazn-data.xml and web.xml
URL Patterns for the pages have assigned to the role.
Login Configuration is HTTP Digest Authentication
<web-resource-collection>
<web-resource-name>APP_SUPPORT</web-resource-name>
<url-pattern>faces/jspx/search.jspx</url-pattern>
<url-pattern>faces/jspx/list.jspx</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>APP_SUPPORT</role-name>
</auth-constraint>
<login-config>
<auth-method>DIGEST</auth-method>
</login-config>
Everything is fine when running the application from JDeveloper,
but when the application is deployed to the server (OC4J),
After logging into the system, the Search page prompt for user id and password again
on click of the Execute button.
Have anyone experience this problem before?
Thanks for any help.
JimHi,
does the same thing happen if you change your protected resource from:
<web-resource-collection>
<web-resource-name>APP_SUPPORT</web-resource-name>
<url-pattern>faces/jspx/search.jspx</url-pattern>
<url-pattern>faces/jspx/list.jspx</url-pattern>
</web-resource-collection>to:
<web-resource-collection>
<web-resource-name>APP_SUPPORT</web-resource-name>
<url-pattern>/faces/jspx/*</url-pattern>
</web-resource-collection>Brenden
Maybe you are looking for
-
Problem with Cyrillic fonts in Mail
I have a problem with Mail mangling Cyrillic fonts. It happens like this: 1. I create a new mail. I set my input locale to Bulgarian - Phonetic. 2. I type out the email and send it to someone (afraid I don't know their config). 3. The other person re
-
Hp Compaq Mini 700-Fatal Error System Halted CNU9122NHV
Hi I us in my computer Linux Mint i think so but now i start my computer and get this message.. Fatal Error System Halted CNU9122NHV. I am not so good in english are from Sweden..And i hope someone can help me.. Thank you!!
-
Most of the music has disappeared from my iPhone!
For no apparent reason about 80% of the music has disappeared from my iPhone, and I am traveling so most of those songs live on my home hard drive and are inaccessible to me. How and why does that happen, and how do I fix it? iPhone 5, iOS 8.0.2. I d
-
How to modify the pre generated SQL string in Db adapter
Hello All, I am using a DB adapter to poll a database. So in the configuration of adapter, i have specified the option of logical delete, i want to update to a field PF as 'Y'. In my BPEL process, I want to update those records as 'Y' for their proce
-
My itunes video playlists (grid view) keep changing to audio playlists
I'm using iTunes 10.7 and stream a lot of movies to my AppleTV. I have video playlists and the AppleTV recognizes them as such. Lately, my video playlists, in the poster art (grid) view, have been changing to audio playlists and changing the order of