How to format Credit card text edit widget? - qt

I am trying to make a custom format for my credit card widget. The first 4 numbers should be followed by a dash '-', then after 3 numbers, another dash and then 2 more numbers.
Example: 1234-678-52.
How can I custom format a text edit so that it has '-' already present and follows the format described above?
The built-in date widget has something similar: having '/' as a delimiter.

If you are using QLineEdit the option is to use the inputMask property:
your_qlineedit->setInputMask("999-9999-99");

You can use three input fields. Place them in one line, draw the '-' in between and add the input masks and some logic.
Input masks: 999, 9999, 99
Logic 1: Go to next input field as soon the input is accepted
Logic 2: Go to previous field as soon all characters are deleted (optional)
The user should now be able to type in the whole number without pressing TAB or '-'.

Related

How can I show the data with comma(,) in drop down box on window?

I have written the program to show all the data on window but stuck in the case for showi a single record with comma(,) in drop down box. Let me share codes what i tried.
DEFINE TEMP-TABLE tt_seq_report
FIELD npai_output_expression AS CHARACTER FORMAT "X(50)".
/* Followings are written inside the drop down box using progress app builder */
/* ON VALUE CHANGED OF coCombo-4 Part Type(Label Name) */
DO:
DEFINE VARIABLE cPartTyp AS CHARACTER NO-UNDO.
CREATE tt_seq_report.
ASSIGN
tt_seq_report.npai_attribute_expression = "22+++,56-".
coCombo-4:ADD-LAST(tt_seq_report.npai_attribute_expression).
END.
When I run the window and select the drop down box then i can see the value upto before comma(,) i.e 22+++ but it should show the full value like 22+++,56-. May I get any help regarding this?
You can set the combo-box'es DELIMITER property to any other character. Comma is just a default.
"Delimiter character can have any ASCII value from 1 to 127. The default delimiter is a comma."

How can I format a time variable to include colons? (JDE Event Rules)

I'm trying to create an ER that adds colons to my time variable in JDE (OMW). I've tried using the substring function to make 3 substrings and then add a colon inbetween each substring, but that doesn't seem to be working for some reason.
Here is what I tried to do as a test to see if the substring would work.
substr([PC Time - Last Updated (F0911) (UPMT)],0,2 )
This should cut my time from an 8 digit number to a 2 digit number, but it doesn't seem to be doing anything. Any ideas? Currently this line of code is in the DO section of my event rules.
You can achieve what you want using the substr function. But you will have to give the function your time. From your code, i can see you used a "PC" variable.
substr([PC Time - Last Updated (F0911) (UPMT)],0,2 )
Which relate to the previous value inside the business view. Maybe you wanted to use a "BC" one? Because the first record will always be null for a "PC" variable Inside a DO SECTION event rule. Just make sure you are sending a value to the substr function.

Progress ABL - strip and add to temp table

I'm coming from a Java/.NET background and trying to learn ABL but the difference in structure and the limited information on the internet is making it hard. What I want to do is import data from a text file which is in the following format:
john smith 52 ceo
...
line by line, and take the different parts based on the position of the character. For example, positions 1-10 are for the first name, 10-20 second name and so on... Do I have to use entry for that? If so can someone more experienced give an example how to do it cause I'm quite confused. Then I need to add a record for each line to a temp-table I have created called tt-employee. How do I go about doing that?
I apologise if my question is a bit vague but as I said, I am new to this so I'm still figuring things out.
If space is a delimiter you can use the IMPORT statement.
DEFINE TEMP-TABLE tt-employee NO-UNDO
FIELD firstname AS CHARACTER
FIELD lastname AS CHARACTER
FIELD age AS INTEGER
FIELD empTitle AS CHARACTER.
INPUT FROM c:\temp\indata.dat.
REPEAT:
CREATE tt-employee.
IMPORT DELIMITER " " tt-employee.
END.
INPUT CLOSE.
However if there isn't a delimiter but rather a fixed record with (as you mention) you can do something like this (error checking and correct record lengths needs to be applied).
/* Skipping temp-table definition - copy-paste from above */
DEFINE VARIABLE cRow AS CHARACTER NO-UNDO.
INPUT FROM c:\temp\indata.dat.
REPEAT:
IMPORT UNFORMATTED cRow.
/* You could replace 0 with a higher number that qualifies a record so
SUBSTRING doesn't return an error if reading past end of line */
IF LENGTH(cRow) > 0 THEN DO:
CREATE tt-employee.
ASSIGN
tt-employee.firstname = SUBSTRING(cRow, 1, 10)
tt-employee.lastname = SUBSTRING(cRow, 11, 10)
tt-employee.age = INTEGER(SUBSTRING(cRow, 21, 2))
tt-employee.empTitle = SUBSTRING(cRow, 23, 10) NO-ERROR.
END.
END.
INPUT CLOSE.
There are several places on the web to look for OpenEdge information:
Official knowledgebase - http://knowledgebase.progress.com/
Official community - https://community.progress.com/?Redirected=true
More communities - http://www.progresstalk.com/ and http://oehive.org/

inserting line breaks after every record in the textpad

I have a textpad file that has rows of text. For e.g.
Cat: Meaning - animal. The cat ran up the house
Rat: Meaning- rodent. The rat lives in the borough and feeds on leftovers
Word 3: Description
Word 4: Description
I have many such record in my file. I want to insert a line break at the end of every record for proper presentation. Doing it manually is tedious. Please help if you know an automated process to insert line break.
You can quickly do this by using a feature called "Regular Expressions" to find and add empty lines.
Open up the Find/Replace (Search menu > Replace)
In the "Find what" field, type the following: (^.+$)\n(^.+$)
In the "Replace with" field, type the following: \1\n\n\2
Tick the "Regular expression" checkbox
Click the Replace All button at least twice, but perhaps 3 times, until you get the message Cannot find the Regular Expression
Untick the "Regular expression" checkbox
Close the Replace dialog
Confirm the file is formatted as you are expecting
Save the file.
You can write a simple C# prgram that uses a loop that adds this code after every line :
But first add the namespace using System.Enviorment
Enviorment.NewLine;
If you have any more trouble i'll help with some code to get started
Open up the Find/Replace (Search menu > Replace)
In the "Find what" field, type the following so that the replace occurs at the end of each line: $
In the "Replace with" field, type the following. Note each 'n' represents a <return>. In this instance, I added a return at the end of a SQL statement, the word 'GO' on the next line and another <return>: \n\GO\n
Started with text file containing:
select * from <tablename>
select * from <tablename>
Ended with text file containing:
select * from <tablename
GO
select * from <tablename>
GO
Hope that helps.
from your text it is difficult to understand what you are intending to do. I'll give you some questions. The answers will help others to help you.
Do you really mean textpad as the product from company helios in UK or do you use this word as a general word for a class of tools (like notepad - but there is a general definition AND the tool as part of Windows).
Your file hase line breaks yet. You don't see them, but in the file itself they are present (in Unix systems line feed (hex code 0A) or in the windows world carriage return followed by line feed (hex code 0D 0A)).
Or would you like to publish your text in HTML? So you have to put the necessary tags around each line like paragraph, line break, list item etc.?

Date Regular Expression Validator

I have a regular expression validator on a text box to validate that the text entered is a valid date.
See reg ex below:
ValidationExpression="^[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}$"
Now I want to allow the following in the textbox: mm/dd/yyyy
How can I update my regex so that if mm/dd/yyyy is entered it does not throw a validation error?
Thanks in advance.
ValidationExpression="^[0-9m]{1,2}/[0-9d]{1,2}/[0-9y]{4}$"
Basically allows 0-9 or m in the first field, 0-9 or d in the second, 0-9 or y in the third (in regular expression [] brackets contain a list of possible options, - denote ranges of values when placed within brackets).
This is a more accurate way to restrict the Date to a more meaningful format
^[1-12]{1,2}/[1-31]{1,2}/[2000-2050,1900-1999]{4}$
This is still not perfect as this will allow - for instance - a date 02/31/2013.
Just realized this is quiet buggy.

Resources