as400 RPGLE wait for input - input

I have an RPG program which prints data with the command DSPLY.
When I call the program,
I can see the printings which appears for a couple of milliseconds,
but it closes right away.
Is there a way in native RPG to make the program wait for input other than using a display file?

Yes, you need to add a response parameter to your DSPLY operation:
/free
dou (response = 'Q');
// dsply 'Q = Quit' '*EXT' response;
// Better to let the RPG runtime determine
// whether to use *EXT (for interactive jobs)
// or QSYSOPR (for batch jobs).
dsply 'Q = Quit' '' response;
if (response <> 'Q');
// your code here
dsply yourvar;
endif;
enddo;
*inlr = *on;
/end-free
Please note - I'm currently unable to test this, I'm just typing the code here straight out of my head.
*Edited to incorporate Barbara's excellent point.

Benny is on the right track, but he left off the response parm.
All you need is:
dsply wMessage *EXT wResponse;
The program will wait till a response is entered. Technically, since any reponse requires enter to be pressed. The user could respond with just enter.

A CL procedure using the Send User Message (SNDUSRMSG) with a default value supplied [Default Reply Value (DFT)] can enable an Inquiry allowing for a pause and just Enter to be pressed to continue. IIRC, even without a default specified, the character string value *N is returned for lack of any input by the user, for which of course a return value of less than two-characters would return only the asterisk; though depending on other setup, that may not be the effect with just Enter, and may instead be seen only with either F11=Delete of the inquiry by the user [or F13=Clear]. Or doing the same code, using whatever message-feature API effects similar; deciding on where to send the message when running as batch vs interactive, might be required by the code using the API vs coding to use SNDUSRMSG for which that feature is built-in.
Note: This usage is of course influenced by the Inquiry Message Reply Handling (INQMSGRPY) setup of the job; e.g. the job could be set auto-reply with the default, such that the inquiry never presents, but that is probably a good thing for consistency/expectation.

Related

Specific issue with a fetch request on input

I have an input field and when on input a function is called. It stops the timeout if there is one, if not then we know the user stopped typing. If the timeout finishes it makes a fetch request to determine if the user's input is valid. Lastly, if the fetch request returns valid, the user's input goes into a list. It will never be valid if a special character exists.
My problem is that when a user enters a valid input, after the 1-second timeout finishes, if the user just happens to within that microsecond window between the fetch and the sending to the list a user enters a special character... the user's valid input plus the special character will go into the list.
My solution is to disable the input field while awaiting the pending promise to resolve (which takes maybe a quarter of a second).
My boss however wants me to see if there is a better solution out there. Since my situation feels rather unique I thought I'd just ask other developers if they perhaps did have a better solution.
Thank you for your help everyone.
The code is something like:
function (){
if (timeoutexists){
clearTimeout
}
timeout = setTimeout ({
submitting = true
fetch user input
submitting = false
if fetch resolve input is valid and put users input in list else it's invalid and do not put user input in list.
})
}

How to create "Round Robin Call Forwarding Function" in Twilio Stack

I have researched high and low through multiple websites and have not found a single fully documented solution for round-robin call forwarding with-in the Twilio stack; let alone within Twilio Studio. The last time this question was asked in detail was in 2013 so your help is greatly appreciated. I am looking to find a solution to the following to educate myself and others:
[Round Robin Scenario]
Mentioned by Phil Krnjeu on Aug 1 '13 at 23:04, "I'm trying to create a website that has a phone number on it (say, a phone number for a school). When you call that number, it has different secretary offices (A,B,C, D). I want to create something where the main number is called, and then it goes and calls phone number A the first time, the second time someone calls the main number, number B is called, C, then D. Once D is called (which would be the 4th call), the 5th call goes back to A."
The response to the above question was to use an IVR Screening & Recording application which requires the caller to pick an agent which is not a true Round Robin solution. The solution I am looking for and many others require the system to know which agent is in a group and which agent is next to receive a call.
[Key Features Needed]
Ability to add forwarding numbers as identified above A, B, C, D as a group or IVR extensions such as 1 = Management, 2 = Sales and etc...
Set a subsequent calling rule that notates in a DB of some sort. Caller A through D, for example, equals 1 unsuccessful. When caller A has been forwarded a call it now equals 0 successful then the script stops and allows the call to be answered by the user or its voicemail. Then the next call comes in and is forwarded to user B and assigned a 0 successful value, then the script stops.
After the caller finishes the call or finishes leaving a voicemail the script needs to end the call.
[Final Destination]
The round-robin should finalize its call with the forwarded phone numbers voicemail.
[Known Issues]
Forwarding a call to multiple numbers not stopping when someone answers
[Options]
Once this question is posted I am sure someone will ask in the near future what if I wanted the call to be forwarded to a Twilio voicemail instead of using the forwarded phone number's voicemail which could be let's say a cell phone. I do not necessarily need this feature, however, making an additional comment would be very helpful to the community. Thank you for your time.
I have limited knowledge of programming besides having the ability to review articles posted by other users. One article I researched in detail that did not work for me was, "IVR: Screening & Recording with PHP and Laravel."
The solution I am looking for first would be to make this code through the new Twilio Studio interface if that is not possible then any other solution would be helpful to all.
Sam here from the Twilio Support Team. You can build what you've described using Twilio's Runtime suite, Studio, and Functions.
I wrote a blog post with detailed instructions and screenshots here, and I've included a summarized version below as well.
CREATE YOUR VARIABLE
First, you need to create a serverless Variable which will be used as the round robin counter. The variable must be inside an Environment, which is inside a Service. This is the only part of the application where you will need your own laptop. You can see how to create these with any of the SDKs or using curl in the docs.
Create a Service
Create an Environment
Create a Variable
Be sure to copy the SIDs of your Service, Environment, and Variable since you will need that for your function.
For convenience, this is how you create the Variable in NodeJS.
const accountSid = 'your_account_sid';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
client.serverless.services('ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.environments('ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.variables
.create({key: 'key', value: 'value'})
.then(variable => console.log(variable.sid));
CREATE YOUR FUNCTION
Create the following Environment Variables here in the console and save set them equal to their respective SID that you saved earlier.
RR_SERVICE_SID
RR_ENV_SID
RR_VAR_SID_CTR
Next, make sure you check the Enable ACCOUNT_SID and AUTH_TOKEN checkbox above the Environment Variables section under Credentials.
Be sure your Twilio Client version in the Dependencies section is set to the latest, so we can be sure it includes the Serverless resources. At the time of writing (March 2020), the default Client version does not include them, so we upgraded to 3.41.1, which was the latest.
Go here in the console and create a blank Function.
Copy and paste the following code and replace the numbers with the ones you would like to include in your Round Robin (make sure the environment variables you just created match what's in the code).
exports.handler = function(context, event, callback) {
// Number List
let numbers = [
"+18652142345", //Sam
"+18651092837", //Tina
"+19193271892", //Matt
// Copy and paste line above to add another number.
];
// Initialize Twilio Client
let client = context.getTwilioClient();
// Fetch Round Robin Ctr
client.serverless.services(context.RR_SERVICE_SID)
.environments(context.RR_ENV_SID)
.variables(context.RR_VAR_SID_CTR)
.fetch()
.then(variable => {
// Use counter value to determine number to call
let number = numbers[variable.value];
// Create var with new ctr value
let ctr = variable.value;
// Check if current counter value is less than RR length (i.e. the number of numbers in round robin)
// If so, increment
if(ctr == numbers.length-1) {
ctr = 0;
}
// Otherwise reset ctr
else ctr++;
// Update counter value
client.serverless.services(context.RR_SERVICE_SID)
.environments(context.RR_ENV_SID)
.variables(context.RR_VAR_SID_CTR)
.update({value: ctr})
.then(resp => {
// Return number to call
let response = {number};
// Return our counter value and a null error value
callback(null, response);
});
});
};
CREATE YOUR STUDIO FLOW
Click the red plus sign to create a new Flow here.
Give the Flow a name and click Next.
Scroll to the bottom of the templates and click 'Import from JSON' and click Next.
Paste the Flow JSON shown here and click Next.
Click the RoundRobin function widget and select the Function you just created under the Default service.
Click the FunctionError widget, click MESSAGING & CHAT CONFIG, and change the SEND MESSAGE TO number to a number that you would like to notify by text in the event of a Function failure.
Click the DefaultNumber widget and change the default number that will be forwarded to in the event of a Function failure.
Click the Publish button at the top of your Flow.
CONFIGURE YOUR TWILIO NUMBER
Go here in the console.
Click the Twilio number you would like to configure.
Scroll down to the A CALL COMES IN dropdown in the Voice section and select Studio Flow.
Select your new Flow in the Select a Flow dropdown to the right.
Click Save at the bottom.
And that's it. You're now all set to test!

How to internationalization errors returned by API?

I'm wondering how to manage error in an API with multiple language.
I know there are multiple way to do that. I found 3.
Send a statusCode to front (with optionnal some data to manage dynamics values like : "you can manage only X users")
Send errors for all language ex :
{
en:"error is....",
fr:"l'erreur est...",
...
}
send just one error in the correct language
{
en:"error is...."
}
All of this have pro and cons...
the first :
+ API just manage statusCode and front(s) can manage error how it want
- API must manage dynamics error and send extra data
- Front must reformat the error (error + extra data)
others ?
the second :
+ error message can just be displayed on front without update it (but need to get the good one for the language client)
- back must manage error message for all language (if there are 10-50 or more language it's a little bit annoying)
- back end must take care of displaying message interstanding for a user (I think it's not is role)
others ?
the third :
+ error message can just be displayed on front without update it
- back end must take care of displaying message interstanding for a user (I think it's not is role)
- front must send the user's language at the session's begining and update this information if user change it
others ?
I think the third is the better but I don't know.
someone could say me what is the best solution and why ?
Thanks in advance :)

Selenium + not able to verify action success using flash message

if(<webelement>.getText() == "Flash_Message_text")
System.out.println(<message to be printed>);
else
System.out.println(<webelement>.getText());
waitFor(3000);
Once I perform an action and it is successful, then a flash message is displayed. As per the above code, I am identifying the flash message and using its text to verify if the action completed successfully or not.
However, it is never executing the "if" part of the code, and it is always printing from the "else" part.
Is there anything I am missing, or is there any other way I can handle this?
Try .equals() instead of == for String Comparison!

Hash character in WCF REST parameter

I have a WCF service that accepts GET calls.
I have a dropdown on my ui that has a list of road exits (exit #1, exit #2, etc.)
When the user selects an exit and mashes a button i call that service with the selected value.
It gets encoded and i can see in fiddler that the end of the url looks like this:
EXIT%20%231
which corresponds to a user selection of EXIT #1
When this param gets to the server, however, all i see in it is the term EXIT.
I think this is related to the hash character having a special meaning in WCF.
Changing that hash tag in my records is not an option. Is there another option to get this to work?
If you have text that is being messed with in transit, you could try base64 encoding before you send it, then decode on the server side.