Search found 327 matches

by hagchr
Tue Jun 10, 2014 11:07 am
Forum: Technical / Scripting
Topic: String Replace Issues
Replies: 11
Views: 8158

Re: String Replace Issues

Hi, RegEx is usually very good for these kind of things. I tried to make a quick one that can hopefully help you. //Read your raw file into variable ReadFile>C:\...\test.txt,strFile //Remove multiple rows and spaces RegEx>(?m)^[^\w]+,strFile,0,M,NM,1,%CRLF%,strFile RegEx> +,strFile,0,M,NM,1, ,strFil...
by hagchr
Fri May 23, 2014 5:11 pm
Forum: Technical / Scripting
Topic: Running a Global Macro in Excel
Replies: 11
Views: 8283

Re: Running a Global Macro in Excel

In Excel, when you are in the VBA environment and press F2 you get the Object Browser. If you look at Application / Calculation (and press F1) you can see there is a property - XlCalculation - that represents the calculation mode: -4105 for Automatic Recalculation -4135 for Manual 2 for Automatic ex...
by hagchr
Thu May 22, 2014 6:31 pm
Forum: Technical / Scripting
Topic: Running a Global Macro in Excel
Replies: 11
Views: 8283

Re: Running a Global Macro in Excel

Not sure, maybe it takes longer to go back and forth the applications and pulling the cell values?? (a question for the experts). If you just want to clean the CSV file there are other options, for example using the MS command "CSVFileToArray" to read the whole CSV file into an array and work throug...
by hagchr
Thu May 22, 2014 4:50 pm
Forum: Technical / Scripting
Topic: Running a Global Macro in Excel
Replies: 11
Views: 8283

Re: Running a Global Macro in Excel

Hi, strange it works on my machine. Did you do any other changes? Maybe you can post your current version?
by hagchr
Thu May 22, 2014 4:05 pm
Forum: Technical / Scripting
Topic: Running a Global Macro in Excel
Replies: 11
Views: 8283

Re: Running a Global Macro in Excel

Hi, I am not an expert on it either so not sure about the optimal code. However, I changed it to the MS format and corrected some errors. Now it will remove the string "vbCrLf" from any used cells. Hopefully it will help you forward. VBSTART Option Explicit Dim xlApp Dim xlBook Sub Main() Const xlSa...
by hagchr
Wed May 21, 2014 8:02 am
Forum: The Water Cooler
Topic: The Unofficial Macro Scheduler Puzzler #9
Replies: 38
Views: 34263

Re: The Unofficial Macro Scheduler Puzzler #9

Sorry, I managed to clean out the two snippets, it looked ok on the screen so I did not realize the problem. Can I put them back or will that not work with links etc? Just to complete my learning experience, If one want message: Let>BinVal=10111010001000010 VBEval>Execute("Bin=""%BinVal%"":Res=0:For...
by hagchr
Tue May 20, 2014 9:40 pm
Forum: The Water Cooler
Topic: The Unofficial Macro Scheduler Puzzler #9
Replies: 38
Views: 34263

Re: The Unofficial Macro Scheduler Puzzler #9

No need for external files, no need for quotation marks... Let>BinVal=10111010001000010 Let>Calc="Bin=""%BinVal%"":Res=0:For I = len(Bin) to 1 step -1:Dig=mid(Bin,I,1):select case Dig:case ""0"":case ""1"":Res=Res+(2^(len(Bin)-I)):end select:Next:MsgBox(""Binary=""&Bin & vbCrLf & ""Decimal="" & Res)...
by hagchr
Tue May 20, 2014 5:00 pm
Forum: The Water Cooler
Topic: The Unofficial Macro Scheduler Puzzler #9
Replies: 38
Views: 34263

Re: The Unofficial Macro Scheduler Puzzler #9

Ok, two more alternatives for the esteemed jury. (Binary string needs quotation marks) Let>BinVal="10111010001000010" WriteLn>%DESKTOP_DIR%\chtestvbxx.vbs,nWLNRes,Set obj=CreateObject("Scripting.FileSystemObject")%CRLF%obj.DeleteFile("%DESKTOP_DIR%\chtestvbxx.vbs")%CRLF%dim Res,I%CRLF%Bin=%BinVal%%C...
by hagchr
Mon May 19, 2014 4:33 pm
Forum: Enhancement Suggestions
Topic: Arrays
Replies: 2
Views: 5683

Re: Arrays

There is a VBS function - Join(list[,delimiter]) - that takes a one-dimensional array and puts the elements together separated by the chosen delimiter. Could that maybe be used?
by hagchr
Sun May 18, 2014 7:59 am
Forum: The Water Cooler
Topic: The Unofficial Macro Scheduler Puzzler #9
Replies: 38
Views: 34263

Re: The Unofficial Macro Scheduler Puzzler #9

Slightly shorter version (not sure if politically correct to use the RegEx replace/result variable to initiate the overall result variable but it seems to work.) Let>BinVal=10111010001000010 RegEx>\d,BinVal,0,Matches,NumMatches,1,0,DecVal Let>ctr=0 While>ctr<NumMatches Let>ctr=%ctr%+1 Let>DecVal={%D...
by hagchr
Sat May 17, 2014 11:16 am
Forum: The Water Cooler
Topic: The Unofficial Macro Scheduler Puzzler #9
Replies: 38
Views: 34263

Re: The Unofficial Macro Scheduler Puzzler #9

Another way to Rome...? Let>BinVal=10111010001000010 RegEx>\d,BinVal,0,Matches,NumMatches,,, Let>DecVal=0 Let>ctr=0 While>ctr<NumMatches Let>ctr=%ctr%+1 Let>tmp=Matches_%ctr% Let>tmp1={Power(2,%NumMatches%-%ctr%)} Let>DecVal=%DecVal%+{%tmp%*%tmp1%} EndWhile MessageModal>Binary = %BinVal%%CRLF%Decima...
by hagchr
Mon May 12, 2014 3:07 pm
Forum: Technical / Scripting
Topic: Change / Reset Keydown Onevent
Replies: 3
Views: 3109

Re: Change / Reset Keydown Onevent

Hi, not sure if there is an easier way, but it seems to work if you add a flag and some lines to the main loop where you reset the old OnEvent and set up the new one: //press a let>event_char_test=a let>teller=0 let>testflag=false OnEvent>KEY_DOWN,%event_char_test%,0,testing SRT>testing let>teller=0...
by hagchr
Mon Apr 07, 2014 3:08 pm
Forum: Technical / Scripting
Topic: Issue with OnEvent - KEY_PRESS
Replies: 4
Views: 3342

JRL, pure coincidence, first it didn't work/trigger. When I aborted the program I happened to press the x-key by mistake, which ended up at the end of the code line. Then the program worked. So it is still odd to me that with parameters and the wrong code at the end it works ok (it triggers when I p...
by hagchr
Mon Apr 07, 2014 9:19 am
Forum: Technical / Scripting
Topic: Issue with OnEvent - KEY_PRESS
Replies: 4
Views: 3342

Issue with OnEvent - KEY_PRESS

A strange thing came up when I was working with the OnEvent and KEY_PRESS. See example script below. If I put in eg. "END>keyx" at the end then it works fine every time. If I put in "END>key" (what I would have expected) then it triggers once and then hangs after I press key 2 or 3. Not sure if a bu...
by hagchr
Wed Nov 27, 2013 1:38 pm
Forum: Technical / Scripting
Topic: Removing the first character in a very large file
Replies: 5
Views: 6243

Hi, I was curious to see if one could use RegEx to solve it. Not sure if there are any upper limits when the file gets much larger but for one million lines it will complete it in around 1 second. Let>InputFile=C:\Users\Christer\Documents\testfile.txt Let>OutputFile=C:\Users\Christer\Documents\resfi...
Sign up to our newsletter for free automation tips, tricks & discounts