Delete the first digit Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
jonyjohny
Posts: 14
Joined: 05 Mar 2018, 06:06

Delete the first digit

08 Mar 2018, 03:45

Hi :), I have a small problem

In the file that creates for me the autohotkey (.txt file) in the 1st line I have 11 digit code, but unfortunately some times it starts with 0 (read from the left). Do you know what formulas to use to delete 0 if it is the first digit on the left?
I have to delete it because it hinders the further execution of the script. And I can not use the function to delete all zeros, because if it is in the middle of a number it must be there
garry
Posts: 1231
Joined: 22 Dec 2013, 12:50

Re: Delete the first digit

08 Mar 2018, 04:37

found this

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: Delete the first digit

08 Mar 2018, 04:44

Code: [Select all] [Download] GeSHi © Codebox Plus

	line := 0123045678900
MsgBox % line := InStr(SubStr(line,1,1),0) ? StrReplace(line,0,"",,1) : line
Return
Tested. RegExFree ;)
jonyjohny
Posts: 14
Joined: 05 Mar 2018, 06:06

Re: Delete the first digit

08 Mar 2018, 06:39

Thanks! :D :D :D
garry
Posts: 1231
Joined: 22 Dec 2013, 12:50

Re: Delete the first digit

08 Mar 2018, 07:44

thank you BoBo
I'm interesting for 3th example : shoul'd remove leading zero's but not the last zero's

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Odlanir
Posts: 274
Joined: 20 Oct 2016, 08:20

Re: Delete the first digit

08 Mar 2018, 09:20

If I'm not wrong, it seems that the specified Dll can't distinguish between trailing and leading chars.
https://msdn.microsoft.com/it-it/library/windows/desktop/bb773454(v=vs.85).aspx
StrTrim function
Removes specified leading and trailing characters from a string.
____________________________________________________________________________
Windows 7 Home Premium 64 bit - Autohotkey v1.1.24.02 64-bit Unicode
garry
Posts: 1231
Joined: 22 Dec 2013, 12:50

Re: Delete the first digit

08 Mar 2018, 11:58

Odlanir , thank you
User avatar
SpeedMaster
Posts: 175
Joined: 12 Nov 2016, 16:09

Re: Delete the first digit

08 Mar 2018, 12:44

Odlanir wrote:If I'm not wrong, it seems that the specified Dll can't distinguish between trailing and leading chars.
https://msdn.microsoft.com/it-it/library/windows/desktop/bb773454(v=vs.85).aspx
StrTrim function
Removes specified leading and trailing characters from a string.


Good stuff 8-)
To remove only trailing characters , we could append first a character and remove it after calling StrTrim()

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

jonyjohny
Posts: 14
Joined: 05 Mar 2018, 06:06

Re: Delete the first digit

08 Mar 2018, 13:07

Code: [Select all] [Download] GeSHi © Codebox Plus

	line := 0123045678900
MsgBox % line := InStr(SubStr(line,1,1),0) ? StrReplace(line,0,"",,1) : line
Return

this code to be very help :)
Is it possible to modify it to delete, for example, only 11 digit? I tried to change the values in it, but if I write anywhere 11, It removes all the same items to 11th place, but I want that It delete only 11 items, which also is 0
User avatar
jeeswg
Posts: 4508
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Delete the first digit  Topic is solved

08 Mar 2018, 19:46

Some ideas, including for your last post, which I believe to mean: 'delete the 11th character if it is a 0'.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

garry
Posts: 1231
Joined: 22 Dec 2013, 12:50

Re: Delete the first digit

09 Mar 2018, 04:04

@jeeswg , thank you for the examples ( at the moment I was specially interesting for the first example ( remove all leading zeros ) )
User avatar
jeeswg
Posts: 4508
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Delete the first digit

09 Mar 2018, 08:09

- Cheers garry np. Yeah, I was surprised nobody else mentioned LTrim, when new functions are added people don't always find out straightaway.
- I thought of one or two further examples that might be useful.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

garry
Posts: 1231
Joined: 22 Dec 2013, 12:50

Re: Delete the first digit

10 Mar 2018, 03:00

@jeeswg , thank you again for the good examples

Return to “Ask For Help”

Who is online

Users browsing this forum: arloseven, Flipeador, imustbeamoron and 11 guests