Using "with" Blocks: Any Problem?

Is the use of with blocks frowned upon among InDesign scripters these days? I'm aware that they are often disfavored in the web world, but I see them used in some sample code I've seen, and being analogous to AppleScript tell blocks, it seems to cut out a lot of repetition or creating non-essential variables. Is there really a risk? Some of the reasoning I've seem mentioned to avoid it involve scoping of variables with the same name, but that could easily be avoided in a personal script, no?

Hi Rc
In my opinion there are 2 issues regarding the use of with.
1) General issues which are the sources of the frowns and the reason why ECMA V5 strict mode bans it use see with - JavaScript | MDN I can not see why those reasons should not apply to Indesign.
2) Specific InDesign issues.
A quick intro for the wider audience.
With can be as far as I know used in 3 ways 1) Method, 2) Property Set 3) Property Get.
The following 2 scripts show how we can apply these 3 ways using and not using with,
// With With
var myRec = app.activeDocument.rectangles[0]; // Note script will crash here if you don't use your brains
var s;
with (myRec) {
    move ([],[10,30]); // method
    rotationAngle = 45; // property set
    shearAngle = 15; // property set
    strokeWeight = 3;// property set
    fillColor = app.activeDocument.colors.itemByName("Cyan");// property set
    strokeColor = app.activeDocument.colors.itemByName("Magenta");// property set
    s = shearAngle;// property Get
// Without With
var myRec = app.activeDocument.rectangles[0]; // Note script will crash here if you don't use your brains
var s;
myRec.move ([],[10,10]); // method
myRec.properties = {
    rotationAngle: 45,// property set
    shearAngle: 15, // property set
    strokeWeight: 3,// property set
    fillColor: app.activeDocument.colors.itemByName("Cyan"),// property set
    strokeColor: app.activeDocument.colors.itemByName("Magenta"),// property set
s = myRec.shearAngle // property get
If you run both script you might think there's not much in it.
Regarding the "method" and "get" usages besides the general "with" issues then I don't think there's much of a difference.
However regarding the "set" usage there can be a very significant difference.  You can see this by running each script and undo the changes made to your rectangle by each script.
Using with you have to undo each and every property setting as each one is applied in turn.
Using properties all the properties are set at the same time and only one undo is needed. (Each property setting can result in a document redraw and a disk writing.
Setting the properties in one go can have a very large difference to the run time of the script.  Although one can reduce this by using redraw = false and FAST_ENTIRE_UNDOMODE using these can sometime be problematic.
However even when scripting Illustrator and the like where one cannot set properties on mass the general issues apply.
My pennies worth,
Trevor

Similar Messages

  • I bought the production premium , cs6 , and I download it and registered with out any problem , I formatted my computer then I downloaded the collection , now everything else working only after effect is not working , what shall i do

    I bought the production premium , cs6 , and I download it and registered with out any problem , I formatted my computer then I downloaded the collection , now everything else working only after effect is not working , what shall i do

    did ae install without problem? check the install logs to be sure (Troubleshoot with install logs | CS5, CS5.5, CS6, CC)
    if it did, what do you see when clicking the executable?

  • Hi, I have an early 2008 24" iMac, I need more storage space and was wondering if I could fit a 3TB Western Digital Caviar Green HDD into it with out any problems? This is the one I've seen, Western Digital Caviar 3TB SATA 6 GB/s 64MB Cache 3.5 inch

    Hi, I have an early 2008 24" iMac, I need more storage space and was wondering if I could fit a 3TB Western Digital Caviar Green HDD into it with out any problems? This is the one I've seen, Western Digital Caviar 3TB SATA 6 GB/s 64MB Cache 3.5 inch

    My bad?
    You're original response was questions/post  about an iMac. Now you've edited it to ask about a Mac Pro?
    You can more easily add internal drives in a Mac Pro.
    Not too terribly easy to add/replace drives in an iMac.
    If younhave questions about a Mac Pro, try posting in the Mac Pro forums.
    Much more knowledgeable users there.

  • I am running FF 6.8 and when trying to download 6.12 I am told I do not have the systems premission to insatall it. I have been using FF for a few years now with out any problems. What has been changed to lock me out of FF upgrades?

    I have downloaded the upgrade and attempted to move it from the application folder to the dock without any luck and when I ask help to check for updates I am told I do not have permission to install updates. I attempted to update FF a couple of months ago and when I encounter this problem I downloaded Safari and installed it. I have tried a couple times along the way to download the upgrade to FF without any luck.

    I just scanned 17 pages of Forum questions and responses and found this response to questions similar ours:
    cor-el 11589 posts 799 answers
    Posted November 16, 2010 7:11:19 PM PST:
    If you have Mac OS X 10.4 or newer then do this:
    • Download a new copy of the Firefox program: http://www.mozilla.com/firefox/all.html
    • Trash the current Firefox application to do a clean (re)install.
    • Install the new version that you have downloaded.
    Your profile data is stored elsewhere in the Firefox Profile Folder, so you won't lose your bookmarks and other personal data.
    Prior to trying this I opened my Profile Folder and then opened My Account to see if my bookmarks were there - I did not find my bookmarks.

  • Canon HV20. Anyone using one? Any problems with iMovie HD?

    So as a follow up to my other post about the Sony, has anyone been using Canon's HV20 with iMovie hd? If I can't get the older Sony to run with iMovie, I'd probably check this out over the Sony HD model, given all the reviews I've read. I really would like an external mic ability, in case I want to use a lavaliere mic for an interview. It appears that the Sony will not allow me to use one. I assume that I can easily plug this model into a MacBook and run it from iMovie, as well as import and edit clips.
    Thoughts?

    There is a box in the top right corner of this discussion group labeled "Search Discussions". Just type HV20 in there. There have been a couple of threads lately on the HV20.

  • TooltipText used with dual screen problem

    Hi,
    In my application I use a dual screen, so JComponent may be either on one screen or the other.
    My problem is when the mouse rolls over a JComponent on the right screen, the Tooltiptext associated is displayed onto the left screen.
    Any idea if I could display it automatically on the good screen or if I have to implement myself the display ?
    Thx for advance

    Did you get any resolution to your question? I have the Samsung monitor almost like yours, and I posted two seconds ago. I think I have a similar problem. I had been using my Samsung with my PC, and just switched to Mac. I loved my Samsung, but now ,for the first time using as a second. Hooked up to mini dvi to dvi, and reported a glow, or tinge coming around any window that I may place on the Samsung.Also, when Ilook at the background around the window I can see that the resolution is not perfect and is breaking up a little. Did you try VGA? and did it help? Curious to know

  • I went to update my facebook app and it keeps saying it cannot download at this time!! All other apps updating/downloading with out any problems, any suggestions??

    My facebook app wont update/download!! Keeps saying it could not download at this time. All other apps are updating/downloading with no problems. Any suggestions please?? Its driving me nuts!!

    https://discussions.apple.com/message/23721474#23721474

  • Voice only plan with Rogers - any problems?

    Hey there - i phoned roger's yesterday and was told a voice only plan that is purchased and costs over 35$ per month is elligble for the 199$ price tag ont he 3G 8GB iphone.
    I was also told that i should not do a voice only plan because as the iphone apparently updates randomly and without your control, i could rack up a bill over 500$ because of data usage when the iphone updates.
    My question is:
    1. is this true?
    and
    2. is there anyway way to work aroudn this so i can use wi-fi for my internet needs and use my voice plan obviously for the phone part without being charge the apparent "500$"
    thanks.

    I think you can turn off the browsing capabilities until you are at a WiFi or your own wireless network. You should have the say over when it updates, just as you would on your computer. So you would just make sure you're in a place where you have free internet access and let it update there.
    But I don't have an iPhone, so this is just speculation.

  • Any problem using bseg and bkpf tables

    For fico details i using  bseg  and bkpf  tables.
    I noted that programming is very difficult because of these tables are cluster table.
    plz give me other tables
    if i using these tables any problem will come?

    >
    mysvijai197715 wrote:
    > Hi Aniesh,
    >
    >            BSEG and BKPF are cluster tables. It contains transperant tables like BSIS, BSIK etc. For example to take vendor details usr the BSIK.If you use BSEG and BKPF it will take long time search. suppose your concern having lot of data means may be your server will get shutdown. So use only trasnperant tables like BSIS, BSIK etc.
    >
    >
    > Regards
    > R.Vijai
    Incorrect.  BKPF is a transparent table and not a cluster table and you can use it just like any other transparent table.  BSEG is a cluster table but there is no problem selecting from it so long as you use the key of BUKRS, BELNR, GJAHR - unless you are selecting a very large amount of data, but then this can cause problems when selecting from any type of table.
    The advantage of using BSEG over the other FI line item tables such as BSIS and BSIK is that it holds all the lines of an FI document while the others will hold only a subset eg BSIK will only hold lines that contain a vendor reference and BSAS holds only cleared GL account lines.  Though you can only use it when you have the key.  If you need to search on vendor, you can use BSIK as a starting point, but since I usually need to get hold of all the lines on an FI document, I then have to select from BSEG anyway.

  • SAP GUI 7.10 overwrites SAP GUI 6.40 once installed and any problem

    Hi,
    Currently I am using SAP GUI 6.40 for my SAP logon,
    but if I install the Internet explorer 7.0 then in SAP transactions F1 help information will not support for this and information on the screen will be blank.
    As per my understanding if we use SAP GUI 6.40 we cann't use the Internet explorer version 7.0. I heard by using SAP GUI 7.10 we can use the Internet Explorer 7.0 with out any problem to F1 help in SAP transactions.
    I have got the path to download the SAP GUI 7.10. If I install will it automatically upgrades the older version, and no more we can use SAP GUI 6.40.Because I am functional consultant I don't know deep about that. So if any problem occurs during the Installation of SAP GUI 7.10 then my SAP log on will be  in problem and cann't use the same SAP GUI 6.40.
    Please share your information on this.How I can go about that without any problem to my SAP activities upon installation. Is there Basis consultant is required for this.
    rgds
    Swamy

    Hi Swamy G S. I'm just install the SAP GUI 6.40 on my test PC -->
    MAIN MODULE INFORMATION:
       Name............: saplogon.exe
       Description.....: SAP Logon для Windows
       Product version.: 640 Final Release
       File version....: 6405.5.26.1027
       Build number....: 917864
    The OS is XP SP2.  The IE 7.0 build 7.0.5730.11
    And the help F1 works fine.
       Try to patch the SAP GUI 640 at least to 26 PL.
    Regadrs.

  • I can not connect to iswifter, some times it is connected and some time it shows " UNABLE TO CONNECT TO SERVER PLEASE CHECK THE INTERNET" but my internet connection is good and other wbe site i can open without any problem. Please guide  me..

    I can not connect to iswifter, some times it is connected and some time it is not connected and getting message " UNABLE TO CONNECT TO SERVER , CHECK YOUR INTERNET" but my internet connection is ok and I can open other web site with out any problem.  Please guide me how to solve this issue.

    Can't connect to the iTunes Store
    http://support.apple.com/kb/TS1368
     Cheers, Tom

  • I am going to buy unlocked iphone 5.. i will be going to india nxt months and will stay there for a while... so my question is will i get warrenty in india.. and will there be any problem with using indian sims..?? thnx for the help..

    i am going to buy unlocked iphone 5.. i will be going to india nxt months and will stay there for a while... so my question is will i get warrenty in india.. and will there be any problem with using indian sims..?? thnx for the help..

    The warranty for the iPhone is not and has never been International.
    Warranty and support are ONLY valid in the country of origin.  The only exception is the EU where the entire EU is treated as one country.
    If the device will be used in India, buy it in India.
    An unlocked iPhone will work on any supported GSM carrier world wide.  The LTE portion of a US purchased, unlocked iPhone is unlikely to work outside North America as it does not support the appropriate bands used in other countries.

  • HT1947 Does anyone else have my problem with atv3? Plays films in iTunes without any problems but on music every time I use the remote app on my iPhone 3GS it stops playing after around 5 tracks in. Anyone having this problem?

    Does anyone share my problem with atv3 I can play films through iTunes without any problems. When I start playing music using the remote app on my iPhone 3GS after around 5 tracks in it just stops playing and seems to lose my connection. Hoping this is human error on my part?

    I think this is probably a sign that your network could be better than it is.
    Intermittent problems are often a result of interference. Interference can be caused by other networks in the neighbourhood or from household electrical items.
    You can download and install iStumbler (NetStumbler for windows users) to help you see which channels are used by neighbouring networks so that you can avoid them, but iStumbler will not see household items.
    Refer to your router manual for instructions on changing your wifi channel or adjusting your multicast rate.
    There are other types of problems that can affect networks, but this is by far the most common, hence worth mentioning first.

  • When attempting to use Lightroom external editor program to edit a photo in Photoshop Elements 10, the photo does not open / appear on photoshop elements screen.  I don't have any problem with this when using Photoshop Elements 6 or Photoshop CS.  I'm usi

    When attempting to use Lightroom external editor program to edit a photo in Photoshop Elements 10, the photo does not open / appear on photoshop elements screen.  I don't have any problem with this when using Photoshop Elements 6 or Photoshop CS.  I'm using a Mac with Mountain Lion OS.  Any solutions?

    Adobe now hides the editor - what looks like it is not - you want the editor hidden in the support folder - see http://forums.adobe.com/message/3955558#3955558 for details
    LN

  • I'm using mac with the newest operating system (snow leopard 10.6.7). since I've updated to Firefox 4 It doesn't display Hebrew fonts- I didn't have any problems with it before the upgrade and in safari I don't have this problem.

    Hello, I'm using Mac with the newest operating system (snow leopard 10.6.7). since I've updated to Firefox 4 It doesn't display Hebrew fonts… I didn't have any problems with it before the upgrade and in safari I have no problem with it. please help me- I don't like to use safari a my browser...

    elly903 wrote:
    Before commenting - I CANNOT install Mavericks because it'll mess up the versions of Filemaker Pro and Quicken that I use regularly...
    Quicken 2007 for Intel (Snow Leopard, Lion, Mt. Lion and Mavericks) for $15:
    http://quicken.intuit.com/personal-finance-software/quicken-2007-osx-lion.jsp
    It will input your Quicken PPC data file directly if it was Quicken 2005 through 2007.  If older you need Quicken 2006 or 2007 PPC first to convert your data file; and this update must be done BEFORE you upgrade to Mavericks:
    http://quicken.intuit.com/support/help/patching/quicken-2006-manual-updates--mac -/GEN82200.html
    Filemaker Pro PPC (in this case 7) running in Snow Leopard Server installed into Parallels for use in Lion, Mt. Lion and Mavericks:
                                  [click on image to enlarge]
    Snow Leopard Server: 1.800.MYAPPLE (1.800.692.7753) - Apple Part Number: MC588Z/A (telephone orders only)
    This solution allows you to run your Photoshop Elements in Mavericks concurrently with Filemaker Pro PPC.  Mavericks is a free download.

Maybe you are looking for

  • TS1363 my computer will not recognize my iphone

    My iphone has been working fine with my computer.  After I did an update for itunes today, the phone froze up  and will not work at all.  It has a picture stating to connect it to itunes, which it is.  The itunes will not recognize the iphone now. he

  • Ipad disabled still after hard reset

    Hello guys, My ipad is disabled, this happend just after I installed the new ios. I locked the ipad because I couldn't remember the 4 digit security system. I followed some instructions about rebooting it, and erasing everything using itunes and when

  • Backing up iphoto 6

    I have a iomega 400g hard drive to backup my photos so i can save space. Read around here and what I did so far is this. I quit iphoto, copied my library folder to my external hard drive, reopend iphoto.... Then what I think im suppose to do is "choo

  • Can't get my Photoshop Touch to run!

    I cannot get my Photoshop Touch for android to startup, or run. It just blinks off, or gives a "Photoshop touch has stopped working" error but will not allow me to report the issue. Can I get some help?

  • Setting mail with iCloud

    Hi, I'm trying to setup mail with my iCloud account but when I use the mail app I can't see my mail. When I go on the iCloud web site everything works fine but it's not working on my Ipad. I can send email with it no problems but I can't see the cont