Jump to content
Macro Express Forums

Macroman

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by Macroman

  1. 10 hours ago, terrypin said:

    Here's one way to do it:

     

    
    // Two cols of info, User ID and Name, separated by a tab, are stored in G:\Traffic\IBS\Other\id.txt.
    This macro prompts for a user id. If it is found it displays the name. Otherwise it displays an appropriate message and ends the macro.
    // I've defined Use ID as a string variable. That not only allows future flexibility but simplifies the script. And unless you intend to do arithmetic on the User ID it's unnecessary to set it as an integer.
    // Note: I prefix my string variables with 't' (for 'text'), and integer variables with 'n' (for 'number').
     
    Variable Set String %tUser%: Prompt
    ASCII File Begin Process: "G:\Traffic\IBS\Other\id.txt" (Tab Delimited Text (.txt))
      If Variable %tUser% Equals "%tLine[1]%" // This is a match.
        Text Box Display: User %tUser% is:
        Macro Stop
      Else
        Repeat Exit
      End If
    ASCII File End Process
    Text Box Display: User %tUser% is:

     

    CODE:

     

    
    <COMMENT Value="Two cols of info, User ID and Name, separated by a tab, are stored in G:\\Traffic\\IBS\\Other\\id.txt.\r\nThis macro prompts for a user id. If it is found it displays the name. Otherwise it displays an appropriate message and ends the macro."/>
    <COMMENT Value="I've defined Use ID as a string variable. That not only allows future flexibility but simplifies the script. And unless you intend to do arithmetic on the User ID it's unnecessary to set it as an integer."/>
    <COMMENT Value="Note: I prefix my string variables with 't' (for 'text'), and integer variables with 'n' (for 'number')."/>
    <COMMENT/>
    <VARIABLE SET STRING Option="\x01" Destination="%tUser%" Prompt="Enter the target User ID." Mask="FALSE" OnTop="TRUE" Left="Center" Top="Center" Monitor="0"/>
    <ASCII FILE BEGIN PROCESS Filename="G:\\Traffic\\IBS\\Other\\id.txt" Format="Tab" Start_Record="1" Process_All="TRUE" Records="1" Variable="%tLine%" Start_Index="1" Parse_Blank_Lines="FALSE" Clear_Array="TRUE"/>
    <IF VARIABLE Variable="%tUser%" Condition="\x00" Value="%tLine[1]%" IgnoreCase="FALSE" _COMMENT="This is a match."/>
    <TEXT BOX DISPLAY Title="User %tUser% is:" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 %tLine[2]%\\f1 \r\n\\par }\r\n" Left="689" Top="334" Width="378" Height="138" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
    <MACRO STOP/>
    <ELSE/>
    <REPEAT EXIT/>
    <END IF/>
    <ASCII FILE END PROCESS/>
    <TEXT BOX DISPLAY Title="User %tUser% is:" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 Not on record.\\f1 \r\n\\par }\r\n" Left="689" Top="334" Width="378" Height="138" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

     

    Terry, UK

     

    MacromanDemo-1.mex 2.98 kB · 1 download

    Terry, I tried the sample macro you provided and it works for the entry on line 1, but not line 2 or 3 any thoughts?   Do you think it'll be better to use a csv file?  Thanks

  2. It's a text file, hasn't much been made yet as I'm trying to figure out how to snag those details.  CSV would be better to organize in my opinion if that's doable. I'm currently using macro express pro

     

    I basically want two columns one with names and one with the numeric user id, and the same with an acronym macro which has two columns of text.  I'm just at home so I don't have access to the macro but I believe it would need a redesign based off what Cory was saying

  3. So i'm trying to make this macro look up a user id number from the text file and display the name associated to it.  If the number doesn't exist, it works correctly.  If it finds the number it displays the whole file.  Any ideas on how to make it just display the person that is associated to it?

     

    Also I want to do the same with acronyms, will the same method still work

     

    I appreciate the help

     

    Thanks

     

    Capture.PNG

×
×
  • Create New...