Jump to content
Macro Express Forums

jay185

Members
  • Posts

    11
  • Joined

  • Last visited

Posts posted by jay185

  1. Variables by their nature are dynamic, otherwise we’d use constants;)

     

    Paul’s routine is the same as I often use though you cause just the CR or the LF, doesn’t need to be both. Paul’s routine will give you the number of instances regardless of how many ‘lines’ there are.

     

    but how do I go on counting the # of characters from a text variable?

     

    when i say dynamic, it refers to copy`ing text from anywhere and putting it into a text variable. sorry if i confuse you guys :)

  2. I have chosen to call my variable %tClip%. You can call it %T[1]% if you like, the difference being that your variable forms the 1st element of an array.

    Let me describe the process to you like this:

    On my clipboard is this text:

     

    The quick

    brown fox

    jumps over the

    lazy dog

     

    This text consists of 4 lines, each of which ends with 2 invisible characters (carriage return = ASCII 13, line feed = ASCII 10)

    So this text is exactly 48 characters long (35 non-space characters, 5 spaces, 4 carriage returns, 4 line feeds).

    If you store this text in a variable, its length will be 48 characters.

    If you now change all carriage return/line feed combinations to nothing, the length of the variable will become 40 (35 non-space characters, 5 spaces, 0 carriage returns, 0 line feeds).

    If you now subtract the new length of 40 from the original length of 48, you get 8.

    If you now divide 8 by 2 (2, because we removed 2 characters for each line), you get 4 - which is the answer to your original question "how many lines of text do I have?".

     

     

    i see what you mean. but what if the text variable is dynamic? this is where i am puzzled. it will compute how many lines that i have copied from clipboard to a text variable...

     

    thanks paul for the explanation :)

  3. This question doesn't make sense! %tClip% is the name of a text variable, into which I have copied the contents of the clipboard (see 1st line of my suggestions).

     

    when you say %tClip% you are referring to the text variable %T[XX]% right? what I dont understand is the saving lenght part. As I understand it, it counts the character of whatever is stored in the text variable.

     

    would it be ok if i request an actual code? so that i can see how it is done.

     

    thanks in advance paul :)

  4. - Save the contents of the clipboard to a variable, e.g. %tClip%

    - Save Ascii 13 to a variable, e.g. %tCr%

    - Save Ascii 10 to a variable, e.g. %tLf%

    - Save the length of %tClip% into a variable, e.g. %nLen%

    - Replace all %tCr%%tLf% with "" (i.e. a zero-length string) in %tClip%

    - Save the new length of %tClip% into a variable, e.g. %nLenNew%

    - Subtract %nLenNew% from %nLen% into a variable, e.g. %nDiff%

    - Divide %nDiff% by 2 - and this is your answer

     

    Beware of any final line in the clipboard - if it doesn't end with %tCr%%tLf%, then you'll need to allow for this (e.g. extract the last 2 characters of %tClip% and compare with %tCr%%tLf% - if unequal, append %tCr%%tLf% to %tClip%).

     

    how do you save the length of a %tClip% into a variable?

  5. that's no challenge, its more like you wanted to be taught step by step how it works, and I bet you know how basing from the number of post that you have.

     

    1. the hta code is set into a variable

    2. the variable then write it as a file.hta

    3. macro runs the created file.hta

    4. while the macro loops until file.hta window disappears, you key in data to the file.hta window, if you close this window, it will output a file.mex file

    5. macro runs the file.mex file getting all the values

    6. macro then displays the value into a window

     

    what you really need to know is vbscript which isn't hard enough.

  6. I actually can't make this to work...

     

    here's my sample.

     

    My code looks like this.

     

    Variable Set Integer %N1% from Prompt

    Variable Set Decimal %D1% from Prompt

    Variable Modify Decimal: Convert %D1% to text string %T1%

    Variable Modify String: Save %T1% to Environment Variable

    Text File Begin Process: "3pm.txt"

      Variable Modify String: Append %T99% to Text File

    Text File End Process

     

    actual script

     

    <IVAR2:01:02:FWhat Time?TFCenter:Center><DVAR2:01:02:FAA DailyTFCenter:Center><DMVAR:05:01:1:000000000000001.0000:1:000000000000002.0000><TMVAR2:19:01:00:000:000:%N1%AAD><BTFBEG:099:000001:000000:C:\Documents and Settings\Administrator\Desktop\3pm.txt><TMVAR2:20:99:00:000:000:C:\Documents and Settings\Administrator\Desktop\3.htmF><BTFEND>

     

    on the text file is an html code... where as it shows

    3pm  %3AAD%

     

    4pm  %4AAD%

     

    5pm  %5AAD%

    thanks a lot

  7. I have a text file that have variables in it. lets say, an html table w/ variables in each table all set to 0.

     

    My problem is, how do I load that text file and save as a different name text file w/ values saved in variable in it?

     

    lets say main.txt contains:

     

    <html><body>

    Box 1 contains %T99%

    </body></html>

     

    then ME will read the file main.txt and replace the value of %T99% to whatever I set it to (e.g. 100), then it will output a file naming mainb.txt then it shoud contain

     

    <html><body>

    Box 1 contains 100

    </body></html>

     

    ........

     

     

    is this possible? if so, please help me...

×
×
  • Create New...