Jump to content
Macro Express Forums

Repeat For New Variable Integer X Times


Recommended Posts

Hi everyone,

 

I am specifically looking to repeat a prompt for new variable integers X number of times.

 

Example: The user will know how many registers they want to edit (ie. 1, 2, 3.. etc.). This will equal the number of new register numbers that need to be prompted for their values. Let's say the user wants to edit 5 registers, and their register numbers are 1, 2, 3, 98 and 99 accordingly. I need a set of commands that will prompt the user 5 times (because the macro already has this value) for a new integer variable equal to the register numbers.

 

Repeat Start (Repeat %EditedRegisters% times)

Prompt for first register number... 1

Prompt for second register number... 2

Prompt for third register number... 3

Prompt for fourth register number... 98

Prompt for fifth register number... 99

 

The number of register numbers changes in each instance, which is why higher in the macro there is a separate prompt that asks how many registers are being edited in total = %EditedRegisters%

 

Does this make sense? Basically I need the macro to understand it needs to prompt X number of times based on %EditedRegisters% for new integer variables which the user will define manually through a prompt.

 

Cheers

Link to comment
Share on other sites

Some ideas:

  1. First prompt the user for the number of values, then use a repeat for that number of times.
  2. Start prompting and when the user cancels or enters no value, exit the loop.
  3. Prompt them only once but instruct them to enter a comma between each value, EG "1,2,3,98,99". Then split those values on the comma.

I like #3 the best. In this case one prompt instead of 6.

Link to comment
Share on other sites

I like #3 too, seems reasonably straight forward. Can you please help me by checking this? I am no wizard.

 

<VARIABLE SET STRING Option="\x01" Destination="%Register[1]%" Prompt="Please enter the registers to edit separated by a COMMA with no spaces inbetween. (ie. 1,2,3,98)" Mask="FALSE" OnTop="FALSE" Left="Center" Top="Center" Monitor="0"/>
<SPLIT STRING Source="%Register[1]%" SplitChar="," Dest="%Register%" Index="1"/>
How do I see my newly created variables? Later on, if I want to use TextType (keyboard function) %Register[1]% will it choose the first register entered to type? If I typed %Register[4]% would register 98 come up?
Link to comment
Share on other sites

That looks like it should work. Also you could allow spaces but before splitting replace all spaces with nothing.

 

After you have these in the string array you could convert to an integer array. Also if you do this in a loop you can do a Try/Catch for each to make sure they don't type anything dumb in.

 

You might need to have a count of the values. In this case you could make a temporary variable and remove all the commas. Then subtract the length of that one from the original and add one which would give you the effective number of elements.

Link to comment
Share on other sites

Hi Cory,

Attached is my MEX file - I thought it might be easier to post the entire thing and ask all my questions rather than waste your time one at a time.

I separated it into Segments (1-6) and Windows (1-3)

 

WIndow 1 = Session A

Window 2 = Session B

Window 3 = Session C

 

Segments are the processes or specific components of what the macro is trying to do.

 

I've added EDIT HERE! comments and tried to explain my case of what I am after and why. Here is a brief summary of these comments by their associated Line Number:

 

Line 3 - I want the entire macro to repeat itself based on the number of rows the user has entered. Example, if the user wants to edit rows 1,2 and 6 (the max is 6 rows per page systematically), the entire macro would repeat 3 times. However, on each repeat, it would start on the next row not already done. For example, if we are repeating 3 times, on the third time the system should start on the 6 row. The value of this row number is the number of types the TAB button is repeated on Line 9, +1 extra TAB, showcased on Line 5.

 

Line 53 - We can see on Lines 54-59, the system is interacting with the user. The system is now showing the first page of registers and asks on Line 54 which register numbers the user wants to edit. It currently saves specific entry as a String, the presses Page Down to go the next page and asks the same question again. This was the original inquiry asked above. Ideally, we just the user to specify what register numbers to edit and the macro saves each one of these as a separate variable to enter as on Line 83.

 

Line 83 - The system is currently prompting the user with a text String that shows the registers they wanted to save for editing later. The user enters ONE of these numbers and it goes through the processes of Segment 4 and 5. Then it repeats the process X times based on Line 60.

 

Line 272 - Ideally based on the Line 3 parameters it would repeat here back to the top.

 

I hope this all makes sense. I am trying my best to describe what I am looking for.

 

 

RegisterMacro1.mex

Link to comment
Share on other sites

What program is MEP operating on? IE where is MEP typing things and for what purpose? IE why doesn't the user just edit these items directly?

 

To be frank I'm a little thick at the moment and I'm not following exactly what you're doing. Also I don't see a question in your last two messages. What can we help you with exactly?

Link to comment
Share on other sites

It sounds like you want a table of values for the user to input or modify. MEP doesn't do user input well. Years ago I wrote many types of interfaces to get around this fact but the fact remains that it's a kludge. One of my easiest ways was to have a Notepad document open and using the controls commands constantly get and set the text to the main editing window. EG I could have a table of figures or several lines of data where the user could edit things. Then I would snab that text and parse out the user's input into my cadre of variables and, if warranted, set the text in Notepad again using those values. If this is the kind of thing you are thinking of you might consider this method.

Link to comment
Share on other sites

Hey Cory, I've attached some screenshots to help identify what I'm looking for. For the purpose of simplifying what I need, let's just focus on lines 49-60 of the MEX file.

Here is what is looks like now:
49: <VARIABLE SET INTEGER Option="\x01" Destination="%PgDownInteger%" Prompt="How many times will we have to press Page Down? There are 6 registers per page down." Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
50: <WINDOW ACTIVATE Title="Session A" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
51: <TEXT TYPE Action="0" Text="<F9>"/>
52: <DELAY Flags="\x11" Time="3"/>
53: <VARIABLE SET STRING Option="\x01" Destination="%RegistersToEdit1%" Prompt="Enter the Register #'s to edit from the first page separated by a space. (ie. 1 2 99). Count how many you're editing." Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
54: <COMMENT Value="EDIT HERE! We want the user to tell the macro which register #'s to edit (ie, 1,2,88 etc.) and have it save each of these entries for a TextType keyboard entry later."/>
55: <REPEAT START Start="1" Step="1" Count="%PgDownInteger%" Save="FALSE"/>
56: <TEXT TYPE Action="0" Text="<PAGE DOWN>"/>
57: <DELAY Flags="\x11" Time="3"/>
58: <VARIABLE SET STRING Option="\x01" Destination="%RegistersToEdit%" Prompt="Enter the Register #'s to edit on the second page separated by a space. (ie. 1 3 98 99). Count how many you're editing." Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
59: <END REPEAT/>
60: <VARIABLE SET INTEGER Option="\x01" Destination="%EditedRegisters%" Prompt="How many registers are we editing in TOTAL at this store? (1 = 1 register)" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>

Line 49: The Macro is asking how many times does it have to page down because the screen only fits 6 registers per page. That is why I've attached a screenshot of Page 1 and 2.
Line 50: Activates the main data entry screen (Session A).
Line 51: Changes the HUD display - irrelevant.
Line 53: Asks the user to type in the registers #'s they want to edit (a TextBox pop-up serves as a reminder later on with this variable)
Line 55: Pages down X times based on Line 49
Line 58: Same as reason as Line 53, except as a new variable. It is unlikely to ever have to Page down 3 times, so having two variables on Line 53 and 58 works.
Line 60: Asks the user how many registers in TOTAL we are editing (ie. 3 registers), NOT the register numbers.

64: <REPEAT START Start="1" Step="1" Count="%EditedRegisters%" Save="FALSE"/>

Line 64: Repeats the next segment X number of times based on Line 60 in the NewWindow (Session B) screenshot.

74: <VARIABLE SET STRING Option="\x01" Destination="%NextRegisterToEdit%" Prompt="FirstPg: %RegistersToEdit1% \r\nSecondPg:%RegistersToEdit%\r\n\r\nWhich register do you want to edit next? (ie. 98 = register 98)" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>

Line 74: Prompts the user to set a new variable String for data entry on Line 83 (circled Register field). The prompt includes the register numbers saved from Lines 53 & 58 so the user doesn't have to 'memorize'.

83: <TEXT TYPE Action="0" Text="%NextRegisterToEdit%"/>

Line 83: Types in the register number from Line 74.


Okay, this is what is happening now. Here is ideally want I want to happen:

Assuming I able to bump Line 55 up and implement a time delay to allow users to identify what register numbers they want to edit, I want one prompt to appear that asks users to specify what register to edit (ie, 1,3,98). The Macro saves this entry as 3 variables: 1,3,98 to be entered on Line 83 after each repeat started on Line 64. Ideally when the user types in they want to edit registers 1,3,98 the Macro saves each of these as variables but also understands and counts there are 3 registers to edit, and saves this as a fourth variable for Line 64.

I hope this makes sense. Once this is automated, the user doesn't have to specify everytime what register they want to edit next as currently set by Line 74.

post-20093-0-66642200-1483469757_thumb.jpg

post-20093-0-21589200-1483469763_thumb.jpg

post-20093-0-38672100-1483469768_thumb.jpg

Link to comment
Share on other sites

Sounds like you have a good idea of what you want to do, what is your question?

 

BTW this looks like a terminal interface. Often times a good terminal emulation software can make a big difference. Most times there is a program that is essentially a TE but only basic capabilities. Decades ago I would use a different TE called ProComm which had added capabilities like the ability to create and run scripts. Sometimes that's worth checking into. One think I found is that ProComm had the ability to (echo) dump all to file. Like in the old days how one would echo to the printer. Then I would change the display parameters so that with long reports make it so that it would display it all on one long page. Of course the user couldn't see it but that wasn't important. In the background I would induct that file and make decisions on it. It saved having to deal with an unknown multitude of screens. And in some cases I'd create my own simplified interface. Gather information and present it, collect and then execute, usually letting the user watch. Also the TE helped tons with timing.

Link to comment
Share on other sites

Q1: How do I have a prompt appear that asks the user what register numbers they want to edit? In screenshot Registers, I want to edit 94,95,96,97, the Macro program should save these as separate variables on Line 83. Additionally, if we create this new prompt and user specifies these 4 registers, we need the Macro to make a new variable that counts how many entries there were. In this case, 4, to be saved for Line 64.

 

Q2: How do I successfully loop this repeat of Lines 64-265 so that after each loop, it types in a new register number on Line 83. Ie. Loop 1 = 94, Loop 2 = 95, Loop 3 = 96. Each new register number entry appears on Line 83 and Line 183 of each loop.

post-20093-0-61572200-1483473981_thumb.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...