I'm using the term elements in my question generically to try to make my question easier to understand. I have this simple prompt to enter a name then print it.
prompt = "Enter a name: "
name = input(prompt)
print(f"\nHello, {name} ")
What I'm having trouble understanding is that if the 'prompt' variable is equal to the statement "Enter a name:" why does it not also display the text in the print statement. Is the input function only accepting input from the user and negates the sentence which the variable is connected to. Thanks for helping me to understand this.
Is the input function only accepting input from the user and negates the sentence which the variable is connected to.
Yes, you are right.
input(prompt) only returns the data that the user entered, not the whole line.
Related
I am creating a custom report screen in which I have a fields item number, item type, prod line and status and there is a condition for item number that is I have to validate it against pt_mstr which from what i understand means that the item number that I enter should be present in pt_mstr. And if it's blank then give an error. I've done the validation for blank with this code
If lvc_part = "" then do:
{us/bbi/pxmsg.i &msgnum=40 &errorlevel=3}
Undo mainloop, retry mainloop.
End.
Lvc_part is the variable i declared for item number and mainloop is the loop inside which I'm writing my entire logic. I am getting the general idea for validating item number against pt_mstr but I'm not getting how to put it down as a code. I'm thinking we need to include a find first query to see if the item number is present in pt_mstr or not but I'm not sure. Any leads would be helpful, if you want to know anything regarding the declarations I've used or anything else let me know. Thanks in advance!
You need to add code like this
IF NOT CAN-FIND (FIRST pt_mstr WHERE pt_mstr.<keyfieldname> = lvc_part) THEN
<display error message>
or when it's a index with multiple fields:
IF NOT CAN-FIND (FIRST pt_mstr WHERE pt_mstr.<keyfieldname1> = lvc_part
AND pt_mstr.<keyfieldname2> = <value>) THEN
<display error message>
Most likely you can (and should) leave out the FIRST phrase in the CAN-FIND expression as typically you'd be using a UNIQUE find here.
My crystal report display not in correct format when I allow one field of it to "Can Grow".
Before allow "Can Grow" :
After Allow :
So how to solve the problem?
Here is what I have set :
Last edit:
Or try this.
Create a text Object.
Insert all your fields in that text Object base in your order.
How to insert? Cut the field then edit text object then paste.
Then in the properties of text object check the Suppress Embedded
Field Blank Line.
Then You can check also if you want the Can grow of text object
This is the Sample Output inside the Textobject
And the output is this
Cotabato to House is the Company name.
Sinsuat to Philippines is the Address.
Then Numbers is the contact.
They compres because i shorten the size of textobject so that they will execute the funtion of can grow
Your Output must be like this. hmmm
Your Final Output must be like this. No more '[' or ']' that can be seen inside the textobject.
Data was just Sample
If it's possible for you, you can create a section just for this field.
If you put your field which can grows and take 2, 3 or more lines in it's own section it will display all the lines but keep it separate from the other fields.
And in the case that it has one line the display will be like you want as well.
Edit : Advantage of this method : you can create a formula in the suppress formula of this new section, like if your text is null or empty, just suppress the section. Like that you can win some space in your report
Regards,
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am passing a username in a session like below and would like to get the first letter of the first name and last name. So for example Doe, John I would like to get "JD" etc. Any idea how I would do this? Thank you
Session("Username")
As an example following your requirements. Lastname stored in first position and firstname stored in last position, but the order of the returned string is First/Last
string username = "Doe, John";
string[] parts = username.Split(' ');
string result = parts[1].Substring(0,1) + parts[0].Substring(0,1);
Console.WriteLine(result);
No error checking is present for clarity, but if you want this for a real work some checks on length of parts is mandatory
If you have only spaces between the parts of the username, try with this RegEx :
initials = Regex.Replace(Session("Username")," *([^ ])[^ ]*","$1")
--> the string "[^ ]" gets every character which is not a space (you can add the char '-' if you want)
By this way, you get a solution which works with people called "John Joe Jibbs" ^^
This is just a proof of concept.
On my form I have a text box for a phone number. I have a regular expression that is fairly universal & can accept almost every variation for a phone number, local or international. the expression is as follows:
^((+)?[1-9]{1,2})?([-\s.])?(((\d{1,4}))|\d{1,4})(([-\s.])?[0-9]{1,12}){1,2}(x?[0-9]{1,})?$
The issue is, the field is not required, but needs to be validated if they decide to enter a number. is there any possible way of doing this?
Surround the entire regex, except the ^ and $ with an extra ( )?
^(((+)?[1-9]{1,2})?([-\s.])?(((\d{1,4}))|\d{1,4})(([-\s.])?[0-9]{1,12}){1,2}(x?[0-9]{1,})?)?$
I don't do ASP programming, but couldn't you do some sort of condition that says something like:
if( textbox.value.length > 0 ) then validate
So it only validates if the user entered something
How to search every word separated by comma in textbox
Please refer above post
Its Working perfectly...But i have small issues.. when i enter in text box like c,c++,4-5 yrs it have to check in database like either c,c++ skills and 4-5 yrs experiecne and then the reult has to be shown... Burt as per ur query it just show results whether any one of keyword satisfy database ...I want to compare year also how? –
If you want that behavior, you have to program that behavior. One design is to have multiple input boxes: one where you check if any of the words exist, another where you check that all of the words exist. (Perhaps even another for an exact phrase match.) Another design possibility would be for you to develop a syntax to indicate optional and required words all within a single input box. The point is it is up to you.
After you've decided on a design, then you could write code that builds your query based on or matches on the optional words and and matches on the required. Something like this pseudocode
Select * From Table Where
(Field Like OptionalWord1 Or Field Like OptionalWord2 Or Field Like OptionalWord3)
And Field Like RequiredWord1
And Field Like RequiredWord2
(etc.)