kcrane Posted November 9, 2010 Report Share Posted November 9, 2010 Here's the simple run down of what I'm trying to accomplish. I have a database (a simple .ini file) with information stored for all my clients. Other people have their own databases, and I need Macro Express to recognize who they are so that it runs off their specific database. What I've got going (and it works fine without switch/case) is a macro that updates information based on a multiple choice selection and prompts. My problem is I need a case for each person, where the destination .ini file will be changed based on who they are. Here's how it basically looks... 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 Am I using the Switch/Case fields incorrectly? The problem I run into is that when I run this macro, it simply crashes with this error: The instruction at 0x7c1b21a referenced memory at 0x00000010. The memory could not be written. If I remove the Case/Switch from it, it runs fine. Thanks for any help here. Quote Link to comment Share on other sites More sharing options...
arekowczarek Posted November 9, 2010 Report Share Posted November 9, 2010 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? Quote Link to comment Share on other sites More sharing options...
kcrane Posted November 9, 2010 Author Report Share Posted November 9, 2010 I think by my omission of a lot of the lines and writing it out in lazy form, I've made it look more confusing than it is. When I get to my home computer I'll take a screenshot and upload it give a better picture, but here's how it looks without the case/switch options: <VARIABLE RESTORE Option="\x01"/> <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="201" Top="155" 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"/> <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"/> <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/> To answer your other question, the macro that determines the name of the person running it is done separately at the start of the work day, ideally. The variable is saved. At the beginning of this macro, variables are restored so that it should carry that information over. Then I would have a case for each name that could potentially be stored in that variable. Case 'Kyle' would run the macro with my own .ini file, while Case 'Liz' would run it with her's. I hope that makes more sense. If it doesn't, I'll try to get a screenshot up. Quote Link to comment Share on other sites More sharing options...
arekowczarek Posted November 9, 2010 Report Share Posted November 9, 2010 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. Quote Link to comment Share on other sites More sharing options...
kcrane Posted November 9, 2010 Author Report Share Posted November 9, 2010 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. The %T[50]% becomes a first name and surname, just like this: John Doe I was going to just use the environment variable %username%, but when I started getting the crash I took that out as a suspect. Here was how my last attempt looked, using %name% in place ot $T[50]% (bearing in mind that there are about 25 if statements before the final end statement, for each menu option). 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? <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"/> <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"/> <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/> Thanks for helping me out so much! Quote Link to comment Share on other sites More sharing options...
arekowczarek Posted November 9, 2010 Report Share Posted November 9, 2010 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 Quote Link to comment Share on other sites More sharing options...
kcrane Posted November 9, 2010 Author Report Share Posted November 9, 2010 (edited) Hmm, the problem is that %T[1]% is the variable that determines where the specific entry goes in the .ini file. For example, the way it works is I run a separate macro that asks me to type a name. If I type 'Johnson', I then use shortkeys like /name and /address for it to type out the name and address belonging to the name Johnson in the .ini file. The .ini looks like this: [Johnson] firstname=Jim lastname=Johnson address= 555 5th St. <------ these are all fields I can type a /add or /surname shortkey for 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. I suppose the solution to that might be to have it store 2 separate variables, both for the same name, have it clear one when I need it cleared and then have it pull the second variable back into it to keep it on track? Let me know if you have another way... I'm under the impression clearing the variable actually clears it and it can't be restored again with the restore variable command. -------- Edit --------- I thought I'd add this as another example of a Case/Switch problem, this time with an error probably unrelated to usage, but maybe not. <VARIABLE RESTORE Option="\x00"/> <SWITCH Variable="%name%"/> <CASE Value="Kyle Crane"/> <VARIABLE SET STRING Option="\x07" Destination="%surname%" Filename="T:\\Claims\\Specialized Services\\Rehab Services & OOP Claims\\Rehab Operations\\Shared\\Macro Express\\kylecrane.ini" Key="%T[1]%" Value="surname"/> <END CASE/> <END SWITCH/> When I run this macro, for the case that %name% has the name Kyle Crane in it, it's supposed to set a variable to an INI file entry. The %T[1]% is the client name from another macro. Anyway, it gives this error: Could not write to the ini file. Access violation at address 7C912C36 in module NTDLL.dll. Write of address 0040621D. Line number 4. Everything was so simple earlier when this was all run locally, but now I'm accessing files stored on a networked drive and I'm running into all sorts of problems. Edited November 9, 2010 by kcrane Quote Link to comment Share on other sites More sharing options...
arekowczarek Posted November 9, 2010 Report Share Posted November 9, 2010 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? Quote Link to comment Share on other sites More sharing options...
kcrane Posted November 9, 2010 Author Report Share Posted November 9, 2010 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? 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 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. Quote Link to comment Share on other sites More sharing options...
arekowczarek Posted November 10, 2010 Report Share Posted November 10, 2010 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 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]" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.