Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NotePad name count
#1
I need a simple macro that will get the text of a name and add
EXAMPLE

NOTEPAD.......................................................................BEFORE

name1
name2
name3 <<<i want the macro to get the last text entered in the notepad and simply copy it but add +1 to it

NOTEPAD------------------------------------------------------------------------------ AFTER

name1
name2
name3
name4
name5
name5 ect....... and keep going till 10 basically get the last number and add one to it... thanks Gintaras
#2
When you press Enter in notepad, takes number from above line, increments and adds in current line.
Macro
Trigger Y /NOTEPAD     Help - how to add the trigger to the macro
Code:
Copy      Help
spe 1
key UHSE
str s.getsel s2
int i
if(s.len and findrx(s "\d+$" 0 0 s2)>=0) i=val(s2)
s=i+1
key DE (s) Y
#3
sorry thats not the code i needed.
that code just adds a 1 to the text or number already existing.
i need a code that will get the number behind the text
EXAMPLE
name1
^ takes the text and number and stores into a string adding +1
so that the outcome is

name2<<<<
#4
Macro
Trigger Cd /NOTEPAD     Help - how to add the trigger to the macro
Code:
Copy      Help
spe 1
key CE U SE
str s.getsel s2
int i
if(s.len and findrx(s "\d+$" 0 0 s2)>=0)
,i=val(s2)
,s.fix(s.len-s2.len)
s+i+1
key DE (s) Y
#5
how do i make that code get the last text from notepad then? from the last line
#6
the macro works well if the last line is followed by new empty line
it gets last nonempty line
#7
Gintaras Wrote:the macro works well if the last line is followed by new empty line
it gets last nonempty line
what i want the macro to do is to get the text from a edit box in a dialog box
then paste it into another id box

Example-
Name1
gets text (Name1)
and pastes into another dialog box.. i dont want it to get the last text from notepad and then paste itnto notepad
#8
ill paste my dialog codes
#9
Function Name
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "5"
str e5
str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 118 "Dialog"
;1 Button 0x54030001 0x4 102 90 48 14 "OK"
;2 Button 0x54030000 0x4 154 90 48 14 "Cancel"
;4 Button 0x54032000 0x0 44 90 48 14 "Run"
;5 Edit 0x54030080 0x200 10 20 96 14 ""
;6 Static 0x54000000 0x0 12 6 48 12 "Name"
;3 Button 0x54020007 0x0 4 0 206 110 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030008 "" "" ""
if(!ShowDialog(dd &Name &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4
,mac "Macro25"
,case IDOK
,case IDCANCEL
ret 1


i want the macro25 to get the text from id(5"Name")
and then count up and paste into another static text.
i was trying to use notepad as an example
#10
Macro
Trigger Cd /NOTEPAD     Help - how to add the trigger to the macro
Code:
Copy      Help
str name
inp- name "name"
spe 1
key CE U SE
str s.getsel s2
int i
if(s.len and findrx(s "\d+$" 0 0 s2)>=0) i=val(s2)
name+i+1
key DE (name) Y
#11
Uhhhhh im getting frustrated with this code... everytime u send me an example it pastes the code into my qm. I dont want the code to paste i just want it to copy into a str so i can set the wintext of a edit box
#12
did not see your post
#13
i dont need any ''key'' code in this file at all. i simply need to copy the text entered in my dialog box and then to store into a string so when i set the wintext it will go from

name1 or name 2 or name 3 or name 4 ect and just change the last number by adding 1 so if name1 it will be name2
#14
Function Name
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "5"
str e5
str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 118 "Dialog"
;1 Button 0x54030001 0x4 102 90 48 14 "OK"
;2 Button 0x54030000 0x4 154 90 48 14 "Cancel"
;4 Button 0x54032000 0x0 44 90 48 14 "Run"
;5 Edit 0x54030080 0x200 10 20 96 14 ""
;6 Static 0x54000000 0x0 12 6 48 12 "Name"
;3 Button 0x54020007 0x0 4 0 206 110 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030008 "" "" ""
if(!ShowDialog(dd &Name &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4
,str name.getwintext(id(5 hDlg))
,int-- i
,i+1
,name+i
,name.setwintext(hDlg)
,case IDOK
,case IDCANCEL
ret 1
#15
Macro
Code:
Copy      Help
str name.getwintext(id(15"Notepad"))
int-- i
i+1
name+i
out name


ok i tested it with Notepad... it works BUT if the text is Name it will out Name1 and if the text is Name1 it will out name11...what i need it to do is ADD1 so if name is name1 it will out as name2
#16
use findrx etc from another example to remove the old number
#17
sorry im not that smart Sad not that good at this stuff but it does help for my work
#18
Macro
Code:
Copy      Help
str name.getwintext(id(15"Notepad"))
str s.getsel s2
int-- i
if(s.len and findrx(s "\d+$" 0 0 s2)>=0) i=val(s2)
name+i+1
out name

this is what i put together but it still dont work. UHH i cant figure this out for the life of me
#19
is this what you want to do? If not, give your version in similar format.

get name from dialog edit control 5
get number from the last line in notepad
number=number+1
name=join name and number
add name to notepad as new line
#20
Gintaras Wrote:is this what you want to do? If not, give your version in similar format.

get name from dialog edit control 5
get number from the last line in notepad
number=number+1
name=join name and number
add name to notepad as new line

i want to
get the text from notepad (name1)
and add it
name1+1= name2
not name1+1 = name11
#21
Macro
Code:
Copy      Help
str s.getwintext(id(15 "Notepad")) s2
s.trim
int i
if(findrx(s "\d+$" 0 0 s2)>=0) i=val(s2)
s.fix(s.len-s2.len)
s+i+1
out s
#22
Thanks!
Thats exactly what i needed Gintaras


Forum Jump:


Users browsing this thread: 1 Guest(s)