Jump to content
Macro Express Forums

arekowczarek

Members
  • Posts

    76
  • Joined

  • Last visited

Posts posted by arekowczarek

  1. @arekowczarek: By default, Macro Express checks every 10 seconds to see if a scheduled macro should run. If the scheduler just checked and one second later the scheduled macro could have run, it will run when the scheduler next checks, 9 seconds later. This may result in the perception that the scheduled macros have a random delay.

     

    You can adjust scheduled macro Timer Interval by clicking Options, Preferences, Activations, Scheduler. Change 'Check the scheduled macros every [ ] seconds' box to 1 second. However, this will use more CPU cycles and, on some systems, may slow down other processes.

    I figured the random delays were somehow connected to the frequency ME checks for scheduled macros. Didn't know I could adjust it in the Preferences, (probably because I don't use scheduled macros at all so the delays are of no significance to me). Good to know anyway, might use this info in the future.

  2. 33.4, 23.8, 0.0 then 33.4, 23.8, -9.6 was my result.

    Now that's hell of a surprise!

    I am getting:

    33.4, 23.8, 0.0 then 33.4, 23.8, -9,60000000000001

     

    If the problem is connected with the floating point, shouldn't we both receive EXACT results running this macro? How can the calculation result be machine dependent??

    Unless of course I am missing here the big picture and floating point calculations are machine dependent. If anyone can confirm they are I'll get down to studying the floating point before bothering you guys anymore.

     

    I'm not sure what you're trying to do and I don't have time to research

    This is just a part of a bigger macro counting the probability of showing desired card combinations. I.E. What is the chance that next two cards taken from the deck are gonna be a "King" and a "9". That sorta stuff.

     

    Thanks Cory

  3. This rings so many alarm bells! I think you'll find that floating point operations (which I assume the Decimal variable is prone to) often result in these types of inexact results - I can remember similar problems in Microsoft Access and VB. If I'm right, then there's nothing Insight ca do for you.

     

    For more information, see:

    Floating Point 1

    Floating Point 2

     

    I read about problems with floating point operations, thanks for the links. I haven't actually understood, yet, why the errors occur (I will get down to it some other time, I know the answer's there, I'm just a lil too busy now and it w'd take me some time to comprehend all that info).

     

    Now, having stated the above, this can be a stupid question, but:

    Shouldn't the error reoccur for the same values in another macro? As mentioned, it doesn't.

     

     

    Thanks for your input Paul

  4. In one of my macros I have three decimals:

    %PROBBEFORE[3]%=33,4

    %PROBAFTER[3]%=23,8

    %DIFFERENCE[3]%=%PROBBEFORE[3]%-%PROBAFTER[3]%

     

    The problem occured only for the values above. I run it about a hundred times, different values each time.

     

    The %DIFFERENCE[3]% should equal "-9,6".

    Instead of this I am getiing "-9,60000000000001".

    It's not just a matter of rounding the result, because 33,4-23,8 ≠ -9,60000000000001

     

    Now, I tried to create a new macro with the decimals preset to the values above - and the error didn't occur.

    So, somehow it only appears in the original macro file. My first thought was that I didn't round the two decimals before the subtraction. But I debugged it and watched the values of decimals. And they equal 33,4 and 23,8 just before the subtraction. and then the subtraction result becomes -9,60000000000001.

     

     

    If anyone wanna give it a quick check I attached the macro file. The macro doesn't interfere with your mouse or keybord (no text type). All you will get are two text boxes. The last three lines of macro is where it happens.

     

    Unless I've made some dumb error myself and somebody can point it out, I'll report it as a bug to ISS.

    MOVE PROBABILITY.mex

  5. I'd like to run macro at the exact time including seconds, for example, 7:59:58

    But I found that ME Pro doesn't allow setting seconds when creating scheduled macro, as below.

    Run the macro : Daily

    Run at : PM 7:59

     

    Is there any way to set the seconds? This, setting seconds, is important to my task.

     

    Thanks in advance.

    Welcome to the forum.

     

    Let's say you have the "MAIN" macro you want to run at 7:59:58

     

    1. Create a scheduled macro "X" that will be run at 7:58 (NOTE: 7:58, not 7:59)

    2. The macro "X" will wait until system time (only minutes and seconds) equals 59:58

    3. At that time the macro "X" will use the Macro run command to run the MAIN macro.

     

    <REPEAT UNTIL Variable="%T[1]%" Condition="\x00" Value="59:58"/>
    <DATE/TIME Format="nn:ss" Flags="\xB0" Date="2010-11-21 09:39:57" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%T[1]%" IsDateVar="FALSE"/>
    <END REPEAT/>
    <MACRO RUN Use_ID="FALSE" Name="THE MAIN MACRO" ID="-1" Wait="FALSE"/>
    

     

    Why not only check seconds? Here's a reason. Scheduled macros are run with some random delays. So, a macro scheduled for 7:59 will actually be run at about 7:59:07. And if you were checking for 59:02 - you would've missed it). The delay differs on my machine. Sometimes it's 2 seconds, sometimes it's 10. So, even if you wanted to run a macro at 7:59:00 (7:59:00 = 7:59) - you actually couldn't, because of the delay. This is also the reason you can't create macro "X" that will be run at 7:59, wait 58 sec, and then run the MAIN macro, because the MAIN macro in this case would be run at about 8:00:02.

     

     

    Hope this helps :)

    1. You post is really about the scroll bars and that needs to be reported to ISS as a bug. But the reason ISS has probably never considered this is that no one should ever have more than about a half dozen nested conditions.
      I don't recall having more than 3 nested conditions ever before. And I am against such nesting myself. But it was (still is) the only way I could think of to process the input data. As for reporting the problem, I requested the horizontal bar as a feature Tracking no. [iSS9224].
       
    2. Anytime one sees huge nested conditions like this the train has gone off the rails. In my experience there is always a way to avoid it. Even if you were looking for words from the bible that don't follow any mathematical order you could at least load all the words used in the conditions into an array and numerically process the array. Sometimes there's a mathematical way, sometimes it's tables of values, sometimes it's a little unconventional but there's always a way.
      I know what you're saying, but storing like, I don't know , 10 000 000 or more words into an array? And you still would need a macro to generate all the words in first place. Plus the words have to be generated only using "letters" available for use in this particiular case.
      I'm pretty sure it's the mathematical way I am using at the moment. I spent like two days trying to figure a unique combination generator and this proved to be the most efficient.
       
    3. I don't know how your macro is working with the 2D bar code but you might want to induct the data value of the bar code into a variable and process that.
      Not sure I follow here. It sort of works like reading barcodes. The idea of the macro is, while having i.e. 2 barcodes, find the least number of pixels that will distinguish one barcode from another. Of course I could read the whole i.e. 16 pixels but the point is it's not efficient. It's not efficient versus only 1 pixel that is necessary to distinguish one barcode from another. That is, provided we know that only 2 barcodes can appear. If there were three barcodes we would need 2 pixels to distinguish one from the others.
       
    4. If you save a graphic like this as a BMP it's fairly simple to decode the BMP into usable data. I wrote a post here about it somewhere. In this case I bet if you save the bar code to a BMP each dot will be something like 4X4 pixels in which case it would be really simple to convert into a string of ones and zeros by processing the bytes of the BMP. Helluva lot better than Get Pixel Color and hyper fast.
      Of course I have all the lines (or: "barcodes") converted into text strings before the MAIN macro starts. During its work the macro doesn't read any pixels off the screen, it works with the text strings that have the pixels values pre-set into them. Reading every combinations of pixels off the screen during macro's run would slower the whole process like a hundred times.
       
    5. There are DLLs that will decode bar codes for you. Might want to check some of them out. Also I know IRIS and other OCR products have the ability to take an image of a bar code from a scan pen or whatever and decode it. Hell, my Android cell phone will decode bar codes!
      Now, the data I work with is in no way regular barcodes. The lines are just random 0s and 1s BUT not only, sometimes they are 0s,1s,2s,3s,4s,5,s etc. That's because my "barcodes" happen to have 10 or even more colours.

     

    Let's assume that I only deal with black and white barcodes that are 100-pixels wide.

    What may be confusing: I know I could read 100 pixels of each bar and it would give me a different binary representation. But that's the whole point of the macro. To limit the number of pixels needed to distinguish one barcode from another. And as stated above, 1 pixel would be enough to distinguish 2 monochromatic barcodes from each other.

     

    I kept puting the barcodes into quotation marks since I do not work with barcodes. They are just pixels retrieved from a picture like i.e. a Mah-Jong tile. And on a Mah-jong example, I need to know which pixels to read to distinguish one tile from the others. Reading a Mah-jong tile all way through would be like 1000 pixels. And yes, it would be unique set of pixels for each tile. But reading 1000 pixels every time I want to know which tile is displayed in a particular spot? No way it could be efficient. Hence the cobination macro. It limited the number of pixels necessary to distinguish one tile from the others down to only 10 pixels (or 11, I don't recall). Reading 1000 px vs 10 px? Certainly worth the hassle.

     

    I wish I could play with this one. Sounds like fun. Good luck!

    Thanks Cory, but I consider the combination macro finished, and since I don't need to tamper with its entrails anymore or do anything else but use it, I'll just let it be. I don't believe there's away to eliminate the nested loops in this particuar macro, so, unless somebody provides a totally different idea of the whole process, I'll just leave the macro alone. I'd love to be proven wrong on this. But for now, the macro does the job it was designed for. The only fault it has is: it doesn't fit the screen. If only I had a 100 inch LCD! (hope you're reading this, Santa) :D

  6. Mehhh... Pretty common knowledge ;-) And as it is with a lot of things in the programming world it's just expected that one needs to do little experiments now and then.

    I do agree about the experimenting part. It's just sometimes, like in this case, for a person who hasn't ever programmed anything in C or ANY other language (except adding two integers in Pascal 10 years ago...unsuccessfully...), and doesn't know how the whole magic happens, it may be difficult to even allow consideration of an experiment. This last sentence probably doesn't make sense at first, just Repeat Until it does :). Even for a non-programmer most ME commands are pretty strightforward and unambiguous, however the usage of IF command mentioned in the OP was not.

     

    Pretty much all my knowledge in ME programming comes from experimenting and help files. From capturing and playing back macros about 3 years ago, to now, writing advanced macros from the scratch. Few times I even happened to provide a throughout solution for my friends to their problems with ME*. Nothing unusual, but some of them are univeristy grade programmers and you wouldn't expect a self-taught rookie like myself to solve their programming problems (but by no means I will claim I am a better programmer/coder than they are!). I'm just an every-day ME addict. One of many.

     

    *FYI

    The problems mainly concerned screen reading in games, no text selection posssible. They write advanced programs in C++ on daily basis, but they simply couldn't figure out how to read whole words off the screen.

    Screen reading and conditioning the results is what I do for pleasure.

     

    I do encourage you to make suggestions to ISS directly. In my experience they're very responsive to suggestion to add information to help files.

    I will suggest addidng the info to them.

     

     

     

     

    Thanks for you comment on this Cory. I feel enlightened now :)

  7. Few month ago I accidently used this IF command in a macro:

     

    If variable %T[1]% is greater than %T[2]%

    do something

    End if

     

    I couldn't figure out what was happening with the macro untill I saw the typo (originally I was supposed to compare %N[1]% and %N[2]%). I didn't know I could compare text strings that way. I figured, macro was checking which variable was longer. I tried it with few random words and my theory proved right. I was like 'Cool, now I will be able to skip "variable set integer to the length of text variable" by simply using the string itself to compare.

     

    Today I tried this "trick" and it wouldn't work. Macro claimed that %T[1]%="john" is greater than "%T[2]%="africa". That left me stunned for 7 minutes.

    Then I realized macro wasn't comparing the variables' length at all. It was checking which of the two variables comes first in the alphabetical order. Which by the way is very handy.

     

    I wish there were some info in ME Help file about this particular use of IF commands. Cause that's where I turn first if I want to see possible uses of a command.

     

    It just sounds so odd, that "b" is greater than "a", and "a" is less than "b" (apart from ie.: if "africa" contains "a" or if "africa" equals "africa".) To me at least.

     

    That's it. No problem to solve, just felt like sharing :) Maybe somebody finds this useful. I searched the forum for posts concerning the topic and didn't found any info on this usage of IF command. I hope it's not because it's such common knowledge that is not worth mentioning, and I was the only one who didn't know about it :D

  8. But your problem will more be the fonts used in the text box. For instance decimal 219 (0xDB) is the block character in extended ASCII but in Arial it's some kind of foreign U character. You can verify this using the Windows Character Map utility. You just need to find the right one for your font or a font that supports

     

    I've seen the Variable Set to ASCII command and I even tried to use it myself for the purpose in the topic, but I failed. I did get that odd foreign U character you're talking about and got discouraged. Not in a hundred years it would occur to me that the problem was the font in the text box!

     

    I was using MS Word to look through the list of block characters (via "Insert symbol"), and there, when I selected Arial I was seeing the block characters I wanted. The problem was I never noticed the option "Unicode(hexadecimal)" was set (and even if I did it still wouldn't give me a clue about what it actually does). Now, when changed to "ASCII(decimal)" no block chars are seen anymore and I only see chars I can use with the Variable Set to ASCII command.

     

    Thank you very much Cory, problem solved and I learned something new. What else could I want? :)

  9. Is it possible to set string variables to characters from Extended ASCII Table?

    i.e. to symbols like these: ■ ▐ ┘ ▒

     

    I know I can have them displayed in the text box correctly if they're put there directly. However, I was thinking of displaying a certain symbol (i.e. "■" or "▐") depending on conditions met. That would require to store the symbols in some kind of a variable. (or I could work around that by displaying a different pre-set text box window according to the conditions met, don't be bothered by the work-around).

    I tried setting a text variable to one of those symbols and no luck (each symbol is converted to "¦").

     

    There's probably a simple explanation to this, and a technical reason for which a text variable wouldn't accept those characters.

    It's just bugging me that the text box accepts those characters, while the string variable doesn't. Can anyone put some light on it?

  10. Aha, thank you, that should work fine. I should have realized that!

     

    As for the problem I posted in my edit above, I realized my mistake and it's corrected now.

     

    Thanks again for your aid :lol: With my Case/Switch problems in the OP, I've gotten around them by doing a horribly long 4000 line macro with an if statement for every person. At least it'll work for the moment.

     

    You're welcome however you pretty much worked your way around the problem yourself. I am about to come up with a way to reduce all the IF's you put up there to just about 20 commands, however I got stuck on the destination all the prompted values are stored.

     

    is kylecrane.ini the file that holds all the records in a way like this:

    [black]

    name=

    surname=

    age=

    etc

     

    [Doe]

    name=

    surname=

    age=

    etc

     

    and others?

     

    Or kylecrane.ini is just a file that holds info for Kyle Crane, which would mean you have a different .ini file for each customer, which creates the question why each of those file would need the section called by the name of the customer. Why "[Johnson]" instead of i.e. "[uSERNAME]"

  11. So if I overwrite %T[1]% with nothing for each multiple choice menu, it will then no longer have the client name stored to know where to input the changes.

     

    Now hold on, I messed it up (I do that every now and then ;).

    I meant %T[10]% not %T[1]%. %T[10]% is the variable responsible for storing the selection of choices from the multiple menu which means the current values stored in this very variable will be pre-marked whenever the multiple choice window appears. You don't use %T[10]% to anything else than to verify what choices were selected, do you?

  12. Seeing as how you are very knowledgable, would you also happen to know to make it so that once multiple options are checked in a menu, the next time the menu runs it doesn't leave the check-marks there from the previous selections?

    I'll start with this since its easy. You just need to clear - in your case - %T[1]% variable before each multiple choice meanu shows up. (or set it to "empty", that's what I do when I need to reset just one variable - it's faster). Both ways will work.

     

    <VARIABLE SET STRING Option="\x00" Destination="%name%" Value="Kyle Crane" NoEmbeddedVars="FALSE"/>
    <SWITCH Variable="%name%"/>
    <CASE Value="Kyle Crane"/>
    <MULTIPLE CHOICE MENU Style="\x01" Result="\x00" Dest="%T[10]%" Title="%T[1]% - Update Database" Prompt="Select all fields you wish to create/update for:   %T[1]%." Options="surname\r\nfist name\r\nclaim number\r\nexposure\r\ndate of birth\r\ndate of loss\r\naddress\r\nphone numbers\r\nfax number\r\ninjury type\r\ngeneral practitioner information\r\nplaintiff council information\r\noccupational therapist information\r\nphysiotherapist information\r\ncounsellor information\r\nchiropractor information\r\nspeech-language pathologist information\r\nhead office examiner\r\nclaims adjuster\r\ncommittee\r\ntort (change to yes, no or settled)\r\nooptort (change to yes, no or settled)\r\nalerts (important things to remember about client)\r\ntaxi (yes or no if account does/does not exist)\r\nPHN #\r\npersonal contact\r\nPart 7 Only (select yes or no)" Left="334" Top="255" Monitor="0" Width="619" Height="389" OnTop="TRUE"/>
    <IF VARIABLE Variable="%T[10]%" Condition="\x06" Value="a" IgnoreCase="TRUE"/>
    <VARIABLE SET STRING Option="\x01" Destination="%T[11]%" Prompt="New Surname:" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
    <VARIABLE SET STRING Option="\x00" Destination="%T[2]%" Value="surname" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x13" Destination="%T[11]%" Filename="T:\\Claims\\Specialized Services\\Rehab Services & OOP Claims\\Rehab Operations\\Shared\\Macro Express\\kylecrane.ini" Key="%T[1]%" Value="%T[2]%"/>
    <END IF/>
    <IF VARIABLE Variable="%T[10]%" Condition="\x06" Value="b" IgnoreCase="TRUE"/>
    <VARIABLE SET STRING Option="\x01" Destination="%T[11]%" Prompt="New First Name:" Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
    <VARIABLE SET STRING Option="\x00" Destination="%T[2]%" Value="firstname" NoEmbeddedVars="FALSE"/>
    <VARIABLE MODIFY STRING Option="\x13" Destination="%T[11]%" Filename="T:\\Claims\\Specialized Services\\Rehab Services & OOP Claims\\Rehab Operations\\Shared\\Macro Express\\kylecrane.ini" Key="%T[1]%" Value="%T[2]%"/>
    <END IF/>
    <END CASE/>
    <END SWITCH/>
    

    I only added the first command to the script, so that the switch has a case to work with. And the macro in this form works just fine on my machine. I get a multiple choice window to set what data I want to edit for Kyle Crane. When I marked A and B, I was prompted to enter name and surname. Does it not work on your PC (I mean the part of your macro the scirpt of which is provided above).

     

     

    Thanks for helping me out so much!

    Haven't helped one bit yet, but we'll get there :)

  13. Ok, it does look clearer now, no sxcreenshot necessary.

    My next question would be: What does the %T[50]% look like after being determined and saved? To make it work with the switch/case it would need to contain only one single name (unless of course the output of the separate macro was stored in i.e. %T[51]% in the form like "John Doe, Jack Black,.....,....." and before each switch one person's name would be retrieved from %T[51]% and put into %T[50]%).

     

    I'd also like to see how the script looks like when the switch commands are used. Preferably in the form of source code rather than a screenshot.

  14.  

    Multiple Choice Menu: %T[1] ## This menu is a list of demographics you can choose to modify--name, age, address, etc

    Switch (%T[50]%) ## T50 is where each case will be, determined by a separately-run macro (John Doe, Jack Black, etc).

    Case: John Doe

    If Variable %T[10]% contains "a", prompt for the 'a' field, then set the 'a' field to a variable

    Variable modify string - send the contents entered into a specific .ini entry

    End if

    After this, I repeat the If/End If statements for each field. When all fields are complete

    End Case

    End Switch

     

    If the outcome of multiple choice menu is stored in %T[1]% why later the macro checks if variable %T[10]% contains "a"? It's just a typo, isn't it? It wouldn't cause the macro to crash for sure (simply the condition wouldn't be met), just trying to figure what is happening there.

     

    Now about the case value that you're saying is delivered by another macro. At what stage does this macro run? I mean, does it look like this:

     

    1. The main macro is run

    2. The separate macro is run to determine %T[50]%

    3. The separate macro is stopped.

    4. The multiple choice box appears

    5. and so on ?

     

     

    Am I assuming correctly that whenever you removed the switch/case, the macro looked like this:

     

    Multiple Choice Menu: %T[1]

    If %T[50]% equals Jack Doe

    If Variable %T[1]% contains "a", prompt for the 'a' field, then set the 'a' field to a variable

    Variable modify string - send the contents entered into a specific .ini entry

    End if

    End if

    If %T[50]% equals Jack Black

    If Variable %T[1]% contains "a", prompt for the 'a' field, then set the 'a' field to a variable

    Variable modify string - send the contents entered into a specific .ini entry

    End if

    End if

     

    Did it?

  15. The point of outlining the concept to you was not to show you that I understood your concept, but to try and persuade you to think about your puzzle from a new angle.

    What new angle? The concept you presented was just describing how the macro works now.

     

    Nowhere in my outline is there any suggestion that you have to determine "all combinations within a set of elements"; indeed, it is this very notion that is causing you all your problems. Your insistence on calculating all combinations is exactly what is leading you astray.

     

    I agree that the combination part is causing the trouble. But how is the macro supposed to now which positions of the text variable should be processed at each given time? This is simple maths, really. Combinations. It's like Lotto. To present a list of all possible draw outcomes you HAVE TO use combinations. If you know a different way - please do share. Calculating all combinations is necessary, if you think otherwise you really (and I don't mean to be rude here) dont't know what you're talking about. All one could do is try to generate the combinations without the use of multiple loops. I know I can't do it, and until someone presents/describes a different way to do it in ME, I will stand by my opinion that it is impossible.

     

    In which case I think you're on your own because you do not appear at all receptive to other suggestions.

     

    Honestly, what suggestions?

    Paraphrasing, the general suggestion you provided was something like:

    “You did it wrong. I would do it better. I can’t say how cause I didn’t try to. I just know I would.”

    Sorry, but this kind of suggestion doesn’t help at all. It's just empty words.

     

     

    Apart from the above, in the first topic I stated that I needed a way to “expand the script editor window so I can see all the lines.” I clearly stated that, I didn’t say I wanted to rewrite the macro to make it fit the window, which means your English is letting you down as well.

     

    If your car doesn’t fit into the garage you don’t buy a smaller car.

    You extend the garage.

    I know I would.

     

    Anyway, thanks for all your contribution Paul. Wish it helped.

     

    __________________________________________________________________________________________

     

     

    Today I noticed that the slider DOES EXIST when looking at the script in the Direct Editor view (and I can see all the lines easily all the way through). However, I find it harder to edit commands in the direct editor and to navigate within the script (no lines numbers available on the side). So I requested the horizontal bar as a feature from ISS. Tracking no. [iSS9224]

  16. Well, I'm merely trying to follow along here, but I'd have thought it was in Post #7 where, in response to Paul's question "Is this useful?" you replied "- Hell yes."

     

    --

    Terry, East Grinstead, UK

     

    Yes, but in post # 9 I'm explaining that I thought that by the "Is it useful?" question he meant "Is the macro you have useful?". Now, what would give me the impression? The fact that the whole concept he provided above that question is the SAME concept my macro works at the moment. Plus he asked "Does this work as a concept [...]?. So I thought he was just describing my macro's concept to make sure he gets it right (because he didn't understand the way the macro works). So yes, his concept is right, I agree, but it's not different from the concept macro works on now. Nothing revelatory there.

  17. My intention was to suggest an entirely different way of designing your macro(s) as I believe that the code you have written with the multiple nested Repeat loops has no chance of being visible (and therefore viable) in the way you want. In fact, display of this code has caused me several problems, some of which have caused ME to crash. So if my idea is useful (and you have indicated that it is), then I think you should abandon the approach you have adopted, and redesign and rewrite your macro using the logic I outlined.

     

    You got me confused here. Where exactly did I indicate that you're idea was useful? And what idea??

    The only way to redesign the script would be to create a brand new numbers combination generator (thats what the huge loop does). I stand by my opinion that there IS NOT a different way to do it than the one I used in the macro. Can you suggest a macro that will provide all combinations within a set of elements?

    For 5 element set it would need to provide these combinations:

     

    1 2 3 4

    1 2 3 5

    1 2 4 5

    1 3 4 5

    2 3 4 5

     

    Although for 5-element set you could even predefine all the combinations (only 5) in a text file/variable or whatever, but what sort of a combination generator do you suggest that would return 200 combinations of 201-element set?

     

    In addition if I need to find a 5-element combination within a 20-element set all I need to do is change one variable value manually - and then the macro looks for 5 elements out of 20 element set instead the 19 out of 20, which means huge flexibility.

    5 out of 20 is 15504 combinations. No way to predefine them if that's what on you're mind.

     

    EDIT:

     

    Or if that was you're idea:

     

    - Create an array of n rows by 200 integer columns (where n is the number of rows you will process).

    - Populate the array with the pixel values

    - Sort the array

    - Eliminate duplicates (do you need to remember eliminated line numbers?)

    - Process the array to determine the smallest number of elements that render each line unique

    - Create output

     

    Then I generally agree because this is the idea of how macro works at the moment. The the implementation is the problem. (well it's not to me cause the macro works and I don't see the necessity or even possibility to rewrite the script)

     

    Process the array to determine the smallest number of elements that render each line unique

     

    is exactly the part for which combinations sequences have to be used. You did not explain how to do it.

    And I figured I need combinations to process the array elements. To generate the combinations I used the multiple repeat commands. As I said, I don't see any other way to generate combinations. And without combinations I don't have the slightes idea how to process the array.

  18. Ah, a mah-jong player perhaps? Are you any good?

    Well, having a macro that dynamically points out which tiles are matching I have to admit: Yes, I am good. ;) That was just to test the combination macro abilities. Mah-jong fits the macro profile perfectly.

     

    Suppose a 2-row array of these values:

    100 1000

    21 8810

     

    A numeric array will correctly sort these rows as

    21 8810

    100 1000

    while a string array will produce the opposite.

    No such thing takes place. Each colour is represented by single character in a text string. If the input pixel line length is 200, then first 200 characters represent values of pixels in first line, next 200 characters represent values of pixels in the second line and so on.

    And yes, I know I could store real pixel colors with the use of padding, but then again - what for? It's way easier to compare visually pixels in the representation colour form.

     

    For comparison:

     

    16777215 represented by 0 -white

    0 represented by 1-black

    255 represented by 3-red

     

    5 pixel line:

    REPRESENTATION COLOURS

    103113

     

    REAL COLOUR VALUES

    _______016777215_____255_______0_______0_____255

     

    (had to use understikes instead of spaces here)

     

    To me there's no doubt the representation colour way is a lot easier to read.

     

    Does this mean you have sufficient information now to resolve your problem?

    I was referring to the macro usefulness itself, I don't see how this would resolve the problem mentioned in the topic.

  19. Does this work as a concept (don't let's worry about the implementation at this stage)?

     

    - Create an array of n rows by 200 integer columns (where n is the number of rows you will process).

    - Yes, however the array is stored as a string variable

    - Populate the array with the pixel values

    - Well, yes, accordingly to a colour, one single character representing a colour

    - Sort the array

    - I do it in a specially prepared MS Excel sheet, I just find if easier (takes up to 3 minutes).

    - Eliminate duplicates (do you need to remember eliminated line numbers?)

    The numbers of coloumns are dynamically assigned, I don't have to do any calculation myself.

    - Process the array to determine the smallest number of elements that render each line unique

    - Yes.

    - Create output

    - Yes.

     

    Is this useful?

    - Hell yes.

     

    See Picture 2 for a detailed step-by-step guide of processing 5 lines of pixels, each being 9 pixel long.

    See Use example for one of possible uses.

    post-4786-083986100 1289176519_thumb.png

    post-4786-000594800 1289176530_thumb.png

  20. Thanks for providing your detailed and very interesting description.

     

    I don't follow here.

    How are the 3rd (3 4 5 2) and 4th (4 5 1 3) lines the same as any of the others? I can see that lines 1 and 2 contain the same numbers, whereas lines 3 and 4 are both unique. What am I missing?

    That was just a typo, it's correct now.

     

    And I don't understand the output. WHat are the 6 pixels in each line formed from?

     

    The 6 pixels (in the case shown in the picture) are pixels at the following positions:

     

    32, 72, 131, 146, 184, 195. Macro copies the values at each of those numbers from each line of pixels, one [line] after another, and puts them together as a string. If it finds different values for each of the 40 lines, it moves on to the next macro.

     

    So, for the 1st line let it be: (the picture is too blurry so let's just assume)

     

    100100

     

    second...

     

    011001

     

    and so on up to the 40th line.

     

    The macros job was to find those pixels that will form the shortest possible set of 40 unique lines of pixels. The reason it stopped at 6 pixels would be there was no unique combination of 5 pixels.

    So the whole output might look like this:

     

    100100 LINE 1

    011001 LINE 2

    011011 LINE 3

    111001 LINE 4

    010001 LINE 5

    ...

    ...

    ...

    100001 LINE 40

     

    So now, if I want to find out which line of pixels is displayed I just read the 6 pixels at the positions mentioned above and if the pixels are i.e. 111001 (where white=0, black=1) and I know that LINE 4 is displayed. Because only LINE 4 would have this particular set of pixels (111001) at the mentioned positions.

     

    Hope it's clearer now :)

     

    P.S.

    And of course the macro input is not restricted to the use of 2 colours (black na white). I explained it in two colours cause it's the easiest way to see tha idea. It'll work same way for 3,5,10,100 or more different colours, where each colour has to have a different character assign to it. (however with a 100 different colors I could pick 5 random pixel positions and they'd probably all create different 5-pixel lines)

  21. How could anyone (including you) ever successfully debug this script? If you are able, using simple English, to describe in detail what this macro is supposed to do, I imagine there would be a better way of achieving your goal. In fact, I seriously doubt if any of us could find a worse way!

    Imagine 40 lines of pixels, each 200 pixel long.

    What the macro does is try to find a combination of pixels at certain positions in the line, to find the smallest number of pixels that will distinguish each single line from the other ones.

     

    See the picture attached now.

     

    However, it have 200 macros to do it.

    Macro KOMBINACJA K=200 finds a combination of 200 pixels within 201 pixel long lines.

    Macro KOMBINACJA K=199 finds a combination of 199 pixels within 200 pixel long lines.

    ...

    ...

    ...

    ...

    Macro KOMBINACJA K=2 finds a combination of 2 pixels within 3 pixel long lines.

     

    Of course if, let's say the macro KOMBINACJA K=18 doesn't come up with a unique combination, the whole operation stops and I am given 19 pixel long combination. (it returns the position in the horizontal line of every one of the 19 pixels)

     

    You'll now ask:

    Why not create ONE macro (instead of 200) that will look for let's say 20 pixels within those 200 pixel long lines, that will distinguish all of them from the others?

    Oh, I’m glad you asked :)

     

    Let's see...

    N=200, K=20

     

    The total count of 20-element combinations within 200-element set is:

    1613587787967350073386147640 combinations!

     

    Well, it's not that bad, it'd take roughly 407 years 3 months and 6 hrs (provided that Windows doesn't crash in the meantime) to check all the combinations. However, it'd still not guarantee a successful result - cause there might not be 20 pixels that will distinguish all the lines. Then I'd need to check for N=200, K=21

    ….and so on until a result is found :)

     

    Now, just to compare, how long it takes to find the *shortest* unique combination of pixels for my macro?

    About 2 minutes. (TWO MINUTES)

     

    (please take a moment to allow this information sink in)

     

    Now, the "shortest" is a little tricky here, cause when my macro finds i.e. 18 long pixel combination, there's a chance that there exists an i.e 14 pixel combination. But those literally few pixels don't matter if you consider the time the calculation took (several hundred years vs 2 minutes)

     

    As for the loop itself:

    What the loop does is to calculate every possible combination within a set of numbers.

     

    So, I'll explain it on the macro KOMBINACJA K=4 example. (it should return all 4-element combinations within 5-element set)

     

    The repeat loop is supposed to provide those following combinations of numbers:

     

    1 2 3 4

    1 2 3 5

    1 2 4 5

    1 3 4 5

    2 3 4 5

     

    Now that was easy. The repeat loop was just few lines long. One Repeat command is responsible for calculation of one number. Now, I didn’t see any other way (I truly believe if it exists it’s gotta be way way slower) to increase the count of numbers calculated without just applying further Repeat commands. Each number has to be calculated separetly, depending on all other numbers calculated, that's a fact.

     

    If you think it is possible to make a macro that will provide all combination within certain set of numbers, without an enormous number of loops contained within each other, I'd love to know how. I want to make clear that at one cycle, the "whole repeat loop" provides one unique combination that wasn't already calculated before. If the numbers were calculated without the consideration of the other numbers, it would lead (and I can confirm IT DID) to a situation when certain combination are calculated more than once. Here's an example:

     

    1 2 3 4

    4 1 2 3

    3 4 1 2

    2 3 4 1

     

    Those four above combinations are all the SAME. One of them is enough, no need to check 2341 if 1234 was already checked. That's why all the repeat start/end commands are contained within each other, to eliminate unnecessary calculations and save time.

     

    As for the debugging - it wasn't necessary. What I did is: I debugged the KOMBINACJA K=3 macro. Then I created KOMBINACJA K=4 macro using a key (those macros are very linear). Debugged it too. Then I just wrote a macro that created macros from KOMBINACJA 4 to KOMBINACJA 200 using the differential key (not sure if that's the right phrase but it sounds so smart I can't stop myself from using it).

     

    Now, that's quite an essay I wrote here. I tried to explain it as clear as possible. Maybe someone will need just what I wrote, in this case I can surely provide the whole macro set.

     

    And I still need a solution for the question in topic.

    post-4786-068560200 1289145101_thumb.png

    KOMBINACJA K=4.mex

    KOMBINACJA K=200.mex

  22. I know you're trying to assign the key as a hot key and I don't know how to do it either. However, do you use shortkey activations for any other macros? If not, you can remove the default shortkey prefix, which is ##, and then assign the key in question (I believe it's called the tilde key) to your macro as a shortkey activation. It works for me - single press of the key and a macro runs.

  23. I have a macro that at one stage contains 200 loops, each contained within the others. The farther into the loop I get, the farther the indent in the script gets. So, to see what's in the very middle of all the loops, I have to disable the previous, let's say, 180 Repeat Start commands. It's seen better on the screenshot I attached.

     

    Is there any way to help it? I know a horizontal slider would do the job, why it's not there is a mystery to me. Or mayby it's not there only on my PC? (ME PRO 4.2.1.1 running on Win XP PRO)

     

    Any other ideas of expanding the script editor window so I can see all the lines in full length without disabling previous commands?

    post-4786-029243000 1289080491_thumb.jpg

    KOMBINACJA K=200.mex

  24. Say i have a keyactivated macro (Alt + 1). Is it possible to let MEX type Alt + 1 without this macro gets activated? Somehow those macros do not work.

     

    Hi there,

    I created two macros, M#1 activated by "ALT+1", M#2 activated by "ALT+2". At some stage M#1 text types "ALT+2". So, whenever I run M#1 and it gets to type "ALT+2", M#2 is started. At this stage I have 2 macros runnning at same time. However, the keystroke "ALT+2" was never send to the program it was supposed to. This happened because if you use a combo of keys, and there are macros assigned to it, the combo pressed will be "used up" to start a macro in first place. If you use that combo again, it will send the keystrokes to the window that is focused (sinced macro activated by that combo is already running and can't be run twice, so MEP simply ignores the combo). However this doesn't solve your problems - since another macro is run.

     

    Well, I assume my explanation might be a little confusing, anyway, here's the cure :)

     

     

    Use Lock Player command in the begging of your main macro. After putting that command in M#1, M#2 was never started and "ALT+2" was successfully sent to the desired window.

     

    Hope this helps

     

    Arek

×
×
  • Create New...