How do you display a users input into an questdlg command?

7 views (last 30 days)
Hello, I am trying to write a code where a User selects the part they want to order, the number of parts, and their name. I want to then display all of this in an fprintf statement, then ask the user if the display is correct for their order. I got the fprintf version to work, but what I would really like is to maybe get my fprintf code to display as thr questions for the questdlg, then have the user read and answer if their order display is correct in the quest dlg. This is what I have so far
clc
clear
close all
PartType=menu('Please select which part you wish to buy','Flange','Bracket','Hinge');
NumParts=input('How many parts do you wish to buy?: ');
BuyerName=input('Please enter the name for the order: ','s');
Parts={'Flange','Bracket','Hinge'};
PT=Parts{PartType};
displayU=fprintf('The user %s is placing an order on %2.0f units of %s',BuyerName,NumParts,PT);
pause
prompt=questdlg('Please review the statement above. Is this correct?','Order Confirmation');
I would like the promt to look more like.... prompt=questdlg('displayU, Is your order correct?','Order Confirmation') so I can remove the fprintf part :)
Thank you in advance!

Accepted Answer

Tommy
Tommy on 12 May 2020
fprintf prints text to a file which corresponds to the supplied file ID or, if you don't supply a file ID, the command window (file ID of 1). You can use sprintf to construct a string with syntax similar to fprintf. How about something like this?
displayU=sprintf('The user %s is placing an order on %2.0f units of %s',BuyerName,NumParts,PT);
prompt=questdlg(sprintf('%s\n\nPlease review the statement above. Is this correct?',displayU),'Order Confirmation');

More Answers (0)

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!