hal9k
Junior Member
Posts: 87
|
Post by hal9k on Nov 15, 2023 12:45:11 GMT -5
I'm collecting a couple of pieces of data from my user with Prompt statements (I was too lazy to create yet another window). If the user responds to the first prompt with the keyboard, the second prompt appears in the same place on the screen. However, if the user responds the first prompt with the mouse, the second prompt displays a few inches away.
Is this intended? Is there a way to keep successive Prompts in the same place regardless of the responding method?
Thanks (yet again!)
|
|
|
Post by Walt Decker on Nov 15, 2023 13:04:53 GMT -5
No. The PROMPT/CONFIRM statements are modified messagebox() API statements. These statements produce modal dialog windows placement of which are governed by the window callback that activated them. If you want to set the messagebox() at a specified position each time it is activated you can 1) create a window form with a static position or 2) create a modal dialog with style bits set to DS.ABSALIGN = &H01.
|
|
hal9k
Junior Member
Posts: 87
|
Post by hal9k on Nov 15, 2023 13:10:19 GMT -5
Kind of what I thought. I'll tell my user that it's a new computer game called "Chase the Prompt".
Thanks again!
|
|
|
Post by Walt Decker on Nov 15, 2023 13:21:34 GMT -5
If you place your message in a function you can re-use the code multiple times simply by changing the information presented without changing its location. In addition, you can simply copy the function and its supporting subs to other apps saving time and effort.
I can give you some code it you so desire.
|
|
|
Post by Rod on Nov 15, 2023 13:29:15 GMT -5
You would get a more structured response with a little code example of what you are trying to achieve. My initial advice is to stop using Prompt. It’s a bit clunky.
|
|
hal9k
Junior Member
Posts: 87
|
Post by hal9k on Nov 15, 2023 13:49:49 GMT -5
As you will see, I'm a very simplistic, old-school coder. Here is the code I'm using to get a beginning and ending date for a report:
1. earlyDate and lateDate are integer dates used for boundary testing. They insure dates are within 100 years of the current date. 2. If bad dates are entered, rather than barking at the user I use the boundary values. 3. I haven't finished testing the logic, but was just curious about the moving prompt window.
t$ = "1/1/" + todayYear$ 'set t$ to 1/1 of this year for def. val PROMPT "Enter the report starting date (m/d/y)"; t$: t$ = TRIM$(t$) IF t$ = null$ THEN t = 0 ELSE t = DATE$(t$) IF t < earlyDate OR t > lateDate OR t$ = null$ THEN rptStart = earlyDate ELSE rptStart = t END IF
t$ = "12/31/" + todayYear$ 'set t$ to 12/31 of this year for def. val PROMPT "Enter the report ending date (m/d/y)"; t$: t$ = TRIM$(t$) IF t$ = null$ THEN t = 0 ELSE t = DATE$(t$) IF t <= rptStart OR t > lateDate OR t$ = null$ THEN rptEnd = lateDate ELSE rptEnd = t END IF
|
|
|
Post by xxgeek on Nov 15, 2023 14:46:53 GMT -5
How about creating a custom prompt? The code is an example of a custom prompt, edit to suit your needs. If you need help with the GUI, or entering/copying from the textbox let us know.
I found that the first time the custom prompt is opened, it is in one place(not where intended), then it appears where I want it on the second attempt, and all attempts there after. So, I just open and close it on the first attempt, and reopen it. Seems to work ok.
Using keyboard or clicking buttons with the mouse makes no difference.
[start] text$ = "Do you want to?" x=x+1 gosub [customPrompt] gosub [customPrompt] gosub [customPrompt] gosub [customPrompt] gosub [customPrompt] gosub [customPrompt] nomainwin wait
[customPrompt] global text$ WindowWidth = 250 : WindowHeight = 130 UpperLeftX=500 UpperLeftY=400 print DisplayWidth print DisplayHeight statictext #customPrompt.header text$, 5, 20, 130, 20 textbox #customPrompt.textbx, 5, 45, 230, 20 button #customPrompt.default "&OK", [confirmYes], ul, 5, 70, 60, 25 button #customPrompt.no "&Cancel", [confirmNo], ul, 70, 70, 60, 25 open "Custom Prompt" for dialog_modal as #customPrompt #customPrompt "trapclose [confirmNo]" customconfirmOpen = 1 if x= 1 then close #customPrompt : goto [start] x=0 wait
[confirmYes] close #customPrompt return
[confirmNo] close #customPrompt end
|
|
|
Post by Walt Decker on Nov 15, 2023 16:27:46 GMT -5
Personally I would not bother with prompting.
1) STATICTEXT DTS.ST1 "Enter beginning date (dd/mm/yyyy)" 2) TEXTBOX DTS.TXT1 3) STATOCTEXT2 DTS.ST2 "Enter ending data (dd/mm/yyyy)" 4) TEXTBOX DTS.TXT2 5) BUTTON DTS.BTN "Submit", BTNSUBMIT, .... 6) OPEN "DATES" FOR WINDOW AS #DTS 7) WAIT
8) SUB BTNSUBMIT BtnHndl$ 9) get text box 1 10) get text box 2 11) do stuff
|
|
hal9k
Junior Member
Posts: 87
|
Post by hal9k on Nov 15, 2023 18:11:51 GMT -5
Thanks guys. I will try to incorporate your ideas.
|
|