cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Isodraw Macro ignores the leading zeroes

sk-3
1-Newbie

Isodraw Macro ignores the leading zeroes

Hi Gang,

I wrote a macro for giving the ICN numbers in the illustrations. It will ask the user some specific inputs. There is a place where it will ask for the starting and ending value numbers. User would give the starting number as 00001 and ending as 0010 (for example). After running the macro when we see the file name and the ICN number in the file, zeroes in front of the value are ignored and it is displayed as 1 and 10. Why Isodraw ignores the zeroes?.

1 ACCEPTED SOLUTION

Accepted Solutions
thendricks
3-Visitor
(To:sk-3)

Looks like there may be some other errors in your macro (Run Macro?) so I parsed out the basics to get you what you needed.

Macro ICN

  Define stval as String

  Define endval as String

  Define partno as String

  Define ata as String

  Define stng as String

  Define base as String

  Define base1 as String

  Define base2 as String

  Define base3 as String

  Define base4 as String

  Define pathI  as String

  Define extI  as String

  Define fname as String

  Define cgmname as String

  Define size as Integer

  stval =get integer "Starting Number"

  endval=get integer "Ending Number"

  partno=get String "Part No."

  ata =get String "ATA"

    while (stval <= endval)

    stng = stval

    base1= "ICN-"

      base2="-A-"

      base3="-X-B-4050G-"

      base4="-A-001-1"

      while (len(stng)<5)

        stng = '0' + stng

      end while

      base =base1+partno+base2+ata+base3+stng+base4

      message base

      stval=stval+1

   end while

End Macro

View solution in original post

10 REPLIES 10
thendricks
3-Visitor
(To:sk-3)

My guess is that the variables you are using for the ICN values are declared as numbers. What you are attempting to capture however, is not a number. Try declaring your values as strings instead.

Hi Trevor,

Thanks for the reply. Below is my code. I have to declare the variables as integers otherwise the values will not get incremented. Any help is appreciated.

Macro Something

define stval as integer

define endval as integer

stval=get integer "Starting Number"

endval=get integer "Ending Number"

while(stval>=endval)

Create text "some point"

stval=stval+1

end while

end macro

thendricks
3-Visitor
(To:sk-3)

My suggestion then is to treat the field as an integer as you have. Before outputting it however you'll want to check the character length of the integer and then prefix the necessary number of zeros. You can then output that value while maintaining your integer variable for incrementing.

thendricks
3-Visitor
(To:sk-3)

Any luck?

I tried the following two ways...

1) Macro Something

          define stval as integer

          define endval as integer

          stval=get string "Starting Number"

          endval=get string "Ending Number"

while(stval>=endval)

          Create text "some point"

          stval=stval+1

end while

end macro


I got output as -0001-A01 and the next number as -00011-A01. It kept on increasing the number of ones at the end.

1) Macro Something

          define stval as string

          define endval as string

          stval=get integer"Starting Number"

          endval=get integer"Ending Number"

while(stval>=endval)

          Create text "some point"

          stval=stval+1

end while

end macro

I got output as -1-A01 and the next number as -2-A01.

No luck:(

thendricks
3-Visitor
(To:sk-3)

I think it best if we go back to what you're attempting to do. '-0001-A01' is not a number (I might be missing something). I had assumed from your original request you were attempting to do the following. Start with '0001' then move to '0002' => '0003' => '0004' and so on.

Can you give an example of three 'sequential' numbers as well as what the input the values from your users are? Is the A01 consistent or does that vary? Might need to have a third input.

In regards to output, what output are your referencing? The create text line won't output the stval variable and there is no message line. Can you provide your full code to look at? If not, with the above requested information I should be able to provide an example, but you'll have to work on the implementation of course.

Hi Trevor, Thanks for your reply.. Below is the code I wrote.

Macro ICN

  define stval as string

  define endval as string

  define partno as string

  define ata as string

  define stng as string

  define base as string

  define base1 as string

  define base2 as string

  define base3 as string

  define base4 as string

  define pathI  as string

  define extI  as string

  define fname as string

  stval =get integer "Starting Number"

  endval=get integer "Ending Number"

  partno=get string "Part No."

  ata =get string "ATA"

while (stval <= endval)

  New

  text font "arial"

  text size 9

  open

  Select all

  Copy

  Close all_windows confirm_no

  New

  Run Macro

  Select all

  Delete selection

  PASTE same_position

  Select None

  Select at 143.189 6.634

  Delete Selection

  base1= "ICN-"

  base2="-A-"

  base3="-X-B-4050G-"

  base4="-A-001-1"

  stng=stval

  base =base1+partno+base2+ata+base3+stng+base4

  text font "arial"

  text size 9

  Create Text 153.711 8.4 base

  Select at 200.455 9.853

  Move Selection (-56.021) (-3.069)

  Move Selection (-0.145) 0.327

  extI=".iso"

  fname=base+extI

  pathI="G:\WORKING FOLDER\iso\"+fname

  save pathI

  stval=stval+1

  close  confirm_no

end while

End Macro



Output I want is

ICN-11111111-A-222222-X-B-4050G-0001-A-001-1

ICN-11111111-A-222222-X-B-4050G-0002-A-001-1

ICN-11111111-A-222222-X-B-4050G-0003-A-001-1 and so on..

-A-001-1 is a string that I am defining it in the macro itself. After running the macro I am getting as

ICN-11111111-A-222222-X-B-4050G-1-A-001-1

ICN-11111111-A-222222-X-B-4050G-2-A-001-1

ICN-11111111-A-222222-X-B-4050G-3-A-001-1 and so on..

Can you provide that example?. I will try to learn and replicate it. Thanks in advance.

thendricks
3-Visitor
(To:sk-3)

Looks like there may be some other errors in your macro (Run Macro?) so I parsed out the basics to get you what you needed.

Macro ICN

  Define stval as String

  Define endval as String

  Define partno as String

  Define ata as String

  Define stng as String

  Define base as String

  Define base1 as String

  Define base2 as String

  Define base3 as String

  Define base4 as String

  Define pathI  as String

  Define extI  as String

  Define fname as String

  Define cgmname as String

  Define size as Integer

  stval =get integer "Starting Number"

  endval=get integer "Ending Number"

  partno=get String "Part No."

  ata =get String "ATA"

    while (stval <= endval)

    stng = stval

    base1= "ICN-"

      base2="-A-"

      base3="-X-B-4050G-"

      base4="-A-001-1"

      while (len(stng)<5)

        stng = '0' + stng

      end while

      base =base1+partno+base2+ata+base3+stng+base4

      message base

      stval=stval+1

   end while

End Macro

Thanks Trevor. I would surely test it out in my office and get back to you.

Thanks Trevor it worked..

Top Tags