0

About supporting diffferent paper sizes, etc.

For that you want to think about TEMPLATES that your code reads in to format the output.

For example your receipt code would be vastly upgraded to read some text file that it uses to tailor the receipt to the printer and client.

For example, I used a rather spiffy HTML file as my template and used variables in my template file to indicate what was to be replaced in that string. EXAMPLE:
&DATE& &TIME&

Would be in the template file. So your receipt printer routine reads that line into a string then you substitute the date and time in the string with the current date/time then print that string.

This template method means you can tailor your system to each client and printer.

0

Thanks a lot James bro. I used mono-spaced font and my problem has solved.
If u don't mind i have another confusion i want to discuss with you. As you know i am developing a pos(want to launch it as a product) and obviously i cannot predict that whether the user will use a receipt printer or A4 printer. So how can i tackle printing formats and paper size e.t.c. for both type of printers?

0

Hi I am learning python and there is these two code snippets but I keep getting an error when I try to run the program.

# survey.py

class AnonymousSurvey():
    # Collect anonymous answers to a survey question.

    def __init__(self, question):
        # Store a question, and prepare to responses.
        self.question = question
        self.responses = []

    def show_question(self):
        # Show the survey question.
        print(question)

    def store_response(self, new_response):
        # Store a single response for the survey
        self.responses.append(new_response)

    def show_results(self):
        # Show all responses that have been given
        print("Survey results: ")
        for response in responses:
            print('- ' + response)

# language_survey.py

from survey import AnonymousSurvey

# Define a question, and make a survey
question = "What language did you first learn to speak?"
my_survey = AnonymousSurvey(question)

# Show the question, and store responses to the question.
my_survey.show_question()
print("Enter q at any time to quit.\n")

while True:
    response = input("Language: ")
    if response == 'q':
        break
    my_survey.store_response(response)

# Show the survey results
print("\nThank you to everyone who participated in the Survey!")
my_survey.show_results()

This is the error message I get:

Traceback (most recent call last):
  File "../Documents/Python Code/language_survey.py", line 8, in <module>
    my_survey.show_question()
  File "../Documents/Python Code/survey.py", line 11, in show_question
    print(question)
NameError: name 'question' is not defined

Process finished with exit code 1

Thanks alot for the help!!!

0

I have the same situation. i'm trying to connect zkteco device(iclock360) from windows server 2012.
When i run the program from localhost it works fine but in production server i ran into this error:

Retrieving the COM class factory for component with CLSID {00853A19-BD51-419B-9269-2DABE57EB61F} failed due to the following error: 800700c1 is not a valid Win32 application. (Exception from HRESULT: 0x800700C1).

Any idea ?

-1

Hi, I have same problem in the past but to circumvent it I wrote a small procedure that remove the "/" from the data and replace it with another ASCII character and also create another procedure function that reconstruct it by inserting back the "/" here is my code in Vb.net hope this help you, also note you have to use longtext in mysql field

Public Function backlashInsert(ByVal mrtfdat As String) As String
'This insert baclash i.e dim mytext as string =backlashInsert("rtf \")
    'insert / into data to keep / in mysql record
    Dim n As Integer = mrtfdat.Length
    Dim nrtf As String = ""
    Dim mchrasc As Integer = 0
    For i As Integer = 0 To n - 1
        mchrasc = Asc(mrtfdat.Substring(i))
        If mchrasc = 92 Then
            nrtf = nrtf & Chr(42)
        Else
            nrtf = nrtf & Chr(mchrasc)
        End If
    Next
    Return nrtf
End Function

Public Function backlaskrep(ByVal mrtfdat As String) As String
    Dim n As Integer = mrtfdat.Length
    Dim nrtf As String = ""
    Dim mchrasc As Integer = 0
    For i As Integer = 0 To n - 1
        mchrasc = Asc(mrtfdat.Substring(i))
        If mchrasc = 42 Then
            nrtf = nrtf & Chr(92)
        Else
            nrtf = nrtf & Chr(mchrasc)
        End If
    Next
    Return nrtf
End Function
0
        I solved 

decimal first;
            decimal second;
            decimal re;
            var b1 = decimal.TryParse(textBox18.Text, out first);
            var b2 = decimal.TryParse(textBox13.Text, out second);
            if (b1 && b2)
            {
                re = first * second;
                textBox19.Text = re.ToString();
            }
0

Hello Dear,
i have problem to multiple two textboxs ,one is Decimal and second i didnt asign .....
Please check code..

   private void textBox18_Leave(object sender, EventArgs e)
        {

            decimal first;
            decimal second;
            decimal re;
            var b1 = decimal.TryParse(textBox18.Text, out first);
            var b2 = decimal.TryParse(textBox13.Text, out second);
            if (b1 && b2) re = first * second;
            textBox19.Text = re.ToString();

        }

I received error. "use of unassigned local variable 're'.

0

You have a gbc.gridy--; on line 142. It's unusual to see code that loads a form from the bottom upwards, also I can't quite see how that works with the +=2 every third pass on line 136. It seems that every 3 passes you add 2 but subtract 1 three times, so won't gridy go negative? (-1 for grid coordinates means "relative").
I'm not saying its wrong, just that it looked odd to me.

0

In my Food Tab, I wanted to achieve this
Click Here

But I only able to get this
Click Here

How can I increase the width of the JTextField which are in Food Tab ? Below is my code

public class FoodOrdering {

    static private JFrame frame;
    static private JTextField textField;
    static private GridBagConstraints gbc;
    static private JLabel[] foodLabel;
    static private JLabel[] labels;
    static private JTextField[] qtyField;
    static private JLabel[] foodImage;
    static private File[] file;
    private static final int ELEMENTS = 9;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    FoodOrdering window = new FoodOrdering();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     * 
     * @throws IOException
     */
    public FoodOrdering() throws IOException {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     * 
     * @throws IOException
     */
        static void initialize() throws IOException {
        frame = new JFrame();
        frame.setBounds(100, 100, 700, 550);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);
        frame.setLocationRelativeTo(null);

        JLabel lblFoodOrdered = new JLabel("Food Ordered");
        lblFoodOrdered.setBounds(529, 11, 81, 14);
        frame.getContentPane().add(lblFoodOrdered);

        TextArea textArea = new TextArea();
        textArea.setBounds(462, 31, 199, 275);
        frame.getContentPane().add(textArea);

        JLabel lblTotal = new JLabel("Total  : ");
        lblTotal.setBounds(519, 315, 46, 14);
        frame.getContentPane().add(lblTotal);

        textField = new JTextField();
        textField.setBounds(575, 312, 86, 20);
        frame.getContentPane().add(textField);
        textField.setColumns(10);

        JButton btnOrder = new JButton("Order");
        btnOrder.setBounds(521, 352, 89, 23);
        frame.getContentPane().add(btnOrder);

        JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
        addIt(tabbedPane, "Foods");
        addIt1(tabbedPane, "Drinks");
        addIt1(tabbedPane, "Desserts");
        tabbedPane.setBounds(23, 11, 400, 450);
        frame.getContentPane().add(tabbedPane);

        frame.setVisible(true);
    }

    static void addIt1(JTabbedPane tabbedPane, String text) {
        JLabel label = new JLabel(text);
        JButton ...
0

Bother you are giving correct format. There is no problem in alignment if i print it on console. Problem in alignment occurs when i print on xps document. The first column appears in perfect alignment. But the data of other 3 columns appears with incorrect allignment

Qty.    Price.     Amount 
10.      100.        1000
   10.      100.        1000
20.        100.        2000
15.       100.          1500
0

Since OpenGL uses the strange system of 1s and 0s to represent location on the screen, I'm trying to figure out how to switch it to standard x, y coordinates like those that are used on a graph. And so far, my searches on the rest of the internet have turned out nothing. So, to clarify:

How do I make it so that the bottom left corner is the starting place of 0,0 instead of the center of the screen, which is where OpenGL Defaults it too?

Here is my code for reference:

#include <iostream>
#include <SDL2/SDL.h>
#include <string>
#include <GL/glew.h>
#include <GL/GLU.h>

std::string projectName = "Testing The System";

SDL_Window *mainWindow;
SDL_GLContext mainContext;

bool init(int height, int width, std::string programName); //Creates Window and prepares program.
bool SetOpenGLAttributes();
void CheckSDLError(int line); //Finds errors in SDL Initialization
bool RunGame(); //Mainly used for event handling
void Cleanup(); //Shuts down windows, etc.
void Background();

int x, y;

bool init(int height, int width, std::string programName)
{
    //Checks SDL Loading.  If it fails, cancels program.
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        std::cout << "Critical Error #001: Failed To Initialize SDL.";
        return false;
    }

    mainWindow = SDL_CreateWindow(programName.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);

    if (!mainWindow)
    {
        std::cout << "Critical Error #002: Failed To Properly Initialize Window" << std::endl;
        CheckSDLError(__LINE__);
        return false;
    }

    mainContext = SDL_GL_CreateContext(mainWindow);

    SetOpenGLAttributes();

    SDL_GL_SetSwapInterval(1);

    glEnable(GL_TEXTURE_2D);

    return true;
}

bool SetOpenGLAttributes()
{
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    return true;
}

void DrawPixel(int x, int y, int r, int g, int b)
{
    x = ...
0

I don't know what your latest code looks like, but here's an example that works...

        System.out.printf("%-30s %10s %10s %10s\n", 
                              "Item", "Quantity", "Price", "Amount");

        String format = "%-30s %10.2f %10.2f %10d\n";
        System.out.printf(format ,"a",1.1,2.0 ,400);
        System.out.printf(format,"bb",100.,20.99,4);

Output is

Item                             Quantity      Price     Amount
a                                    1.10       2.00        400
bb                                 100.00      20.99          4