issue with Position looking for //

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

issue with Position looking for //

Post by Djek » Wed Apr 09, 2014 12:30 pm

hi all,

I have a compiled script running daily since 2010 without problems.

But when i try to compile/run this same script with the latest version of MS i get a weird behaviour. (syntax error en unable to parse)

I could narrow the error down to the line:

Position>//,%regelmapwelke%,1,gevonden

this reads a source and looks in a textfile for // and if found,
then var gevonden will be 1 (the // is in the first two of the line)
else gevonden will be 0

Well now the shit hits the fan; if i run this sript in the latest version the var gevonden is 0.
So the // cant be detected!
If i replace the // for ** or other characters the script runs ok.

wel, i know in MSsyntax the // is meant to be a Remark, and i use it al lot.
But somehow the // after the position command causes trouble now.
And it wasnt years ago.
Is this a bug or designed to do so?
If so, I must rewrite my scripts.
Thanks for helping me out.
kind regards
Djek

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Apr 09, 2014 2:08 pm

Hi,

I can't replicate any problem. Here's my test script:

Let>regelmapwelke=111///222
Position>//,%regelmapwelke%,1,gevonden
MessageModal>gevonden

If I run this it tells me "4" which is correct.

If I compile it and run the .exe it also tells me "4".

I've tested in 14.1.02

An inline comment must be at the end of the line and must be within /* ... */ so that is not the issue.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Wed Apr 09, 2014 2:54 pm

Have you tried using a variable for the search string?

Let>DblSlash=//
Position>DblSlash,%regelmapwelke%,1,gevonden
Thanks,
Jerry

[email protected]

User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Post by Djek » Fri Apr 11, 2014 8:03 am

thanks Marcus and Jerry,

i think i have to rewrite this script, the cause of the problem looks not be the double slashes.
But what then cause is? I do not know.
Well i still want to know, is there someone who wants to take a look into my corrupted source and find out what i did wrong?
What troubles me, is that i once managed to compile this and the original exe still runs, so it must a typo error made after i compiled this.
Of course, if you detect the error, forever lasting thankyou will be the reward.

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
// kopie van source Marcus ivm maakmap

//marcus source works so the cause is not the //
   let>djek=stupid
   if>djek=notstupid,kkoopp
     Let>regelmapwelke=111///222
     Position>//,%regelmapwelke%,1,gevonden
     Message>gevonden
     wait>0.5
   endif
label>kkoopp



//djek source but what causes the syntax error ? in line 28 ?
    let>gevonden=0
    Let>k2=1
    let>nVervers=1
   Label>startwelke
    Let>dialog1.Msprogressbar1=%k2%
    Let>regelmapwelke=111///222

    If>regelmapwelke=##EOF##,finishwelke
      Position>//,%regelmapwelke%,1,gevonden
      if>gevonden=0
        MidStr>regelmapwelke,1,2,submapwelke
        if>submapwelke=R-
          Separate>regelmapwelke,-,map_names
          if>%map_names_3%=F
            let>rechten="%map_names_2%":123456789ABCD;12456 /D "%map_names_2%":;7
          endif
          if>%map_names_3%=R
            let>rechten="%map_names_2%":R
          endif
          if>%map_names_3%=Q
            let>rechten="%map_names_2%":F
          endif
          // //B erbij gezet rev 300310
          run>cscript.exe %iniplaats%\xcacls.vbs "%voorgaandedir%" /E /G %rechten% /I REMOVE
          let>kk=%kk%+1
          let>nVervers=%nVervers%+1
          if>nVervers>15
            let>kkk=%kk%/%aantalrechten%
            let>kkk=%kkk%*100
            if>kkk={round(%kkk%)}
              let>kkk={round(%kkk%)}
            endif
            DeleteFile>%iniplaats%\mapstat.txt
            let>kkk=%kkk%+10
            WriteLn>%iniplaats%\mapstat.txt,gge,%kkk%
            let>nVervers=1
          endif
         else
          CreateDir>%werkpad%\%regelmapwelke%
          let>voorgaandedir=%werkpad%\%regelmapwelke%
          GetTime>tijd
          getdate>datum
          WriteLn>%iniplaats%\maakmaplog.txt,varuit,%datum% %tijd% %werkpad%\%regelmapwelke%
          run>cscript.exe %iniplaats%\xcacls.vbs "%voorgaandedir%" /G "administrator":F /I REMOVE
          run>cscript.exe %iniplaats%\xcacls.vbs "%voorgaandedir%" /E /G "system":F /I REMOVE
          run>cscript.exe %iniplaats%\xcacls.vbs "%voorgaandedir%" /E /G "remie\mapmaker":F /I REMOVE
        endif
      endif
      Let>k2=k2+1
      Goto>startwelke
      Label>finishwelke
      Label>finishlijst
    endif
   label>stop
    MessageModal>Klaar met aanmaken van %maphoofd%
////////////////////////////////////////////////////////////////////////////////////////

Thank you !

kind regards
Djek

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Apr 11, 2014 1:24 pm

With the code, as submitted, the "syntax error" problem seems to be with the lines:

Code: Select all

if>kkk={round(%kkk%)}
  let>kkk={round(%kkk%)}
endif
If you remark out those lines or if you place a Let>kkk=0 above line 28, the script will run fine. I'm suspecting that Macro Scheduler is evaluating those lines even though the nest of "If"s does not actually process those lines with the given value of variable "regelmapwelke". Since you can't round a text string there is a syntax error. The syntax error is reported on line 28 because that was the last line evaluated by the script processor.

Hope this makes sense.

User avatar
Djek
Pro Scripter
Posts: 147
Joined: Sat Feb 05, 2005 11:35 pm
Location: Holland
Contact:

Post by Djek » Fri Apr 11, 2014 6:24 pm

you really don't know how much this means to me.
I have looked and put breakpoints almost everywhere, and it was drivin me nuts.
I could not see it at all.

Thanks, JRL !!

I think now I can patch my script so that it works again.
:D

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts