Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating a New Dialog
#1
Where do I find a tutorial on designing a dialog I am presently using dialog2 which is a find and replace dialog but I wanted to make it just a find dialog but i am somewhat lost on how to do this.
#2
Sorry I forgot to say that I wanted a very simple dialog to learn on. I was trying to write a dialog that would find a text in an outlook 2010 email message. I have tried to set up a dialog by just using new dialog but it is confusing. I gather I have to run the dialog from within a macro and I realize that I might have to have a find function. But that is far as I have gotten.
#3
All dialog info is in single Help topic "Dialogs".
More difficult is to add the "find" functionality. Do you already created "find" code that works without a dialog? Or do you know to do it?
#4
I want to know how to do it. There seem to be a great number of ways to find and I find the selection confusing. I want to find text in outlook or word and then of course once found I want to either copy them into a universal string or something similar to be used later.
#5
I went to help and saw that the tutorials I needed where at the end of the help section on dialogs. Many thanks.
#6
I am trying to find <<**>> which acts as a "bookmark" and I need to select the bookmark.
I wrote the following but it does not find the subject I get an error which says
Error in FIND __: empty block. Did you forget to tab-indent following lines?.

str subject = "<<**>>"
findrx(subject "" 0 2)
sel subject
#7
Why is 'sel subject' here?
#8
I was planning to put this in a global string with the next step. I am trying to learn the findrx command.

Ideally I would like to find a series of strings that have been put in earlier. Highlighting or Selecting each of them. I plan to combine all of this using a dialog box.

I am trying to duplicate a macro I used in Quickeys for many years.

Thanks as always for your help.
#9
the reason you are getting an error is because of sel subject.
You need case statements after sel
(e.g..,
str weekday.time("%A")
sel weekday
,case "Monday"
,out "today is Monday"
,case "Tuesday"
,out "today is Tuesday"
,case "Wednesday"
,out "today is Wednesday"
,case "Thursday"
,out "today is Thursday"
,case "Friday"
,out "today is Friday"
,case "Saturday"
,out "today is Saturday"
,case "Sunday"
,out "today is Saturday"
also your findrx statement is incorrect
as well as your subject string
str s="dog<<**>>cat"
str subject = "\<\<\*\*\>\>"
findrx(s subject 0 0 s)
out s
#10
Thanks for the help on the subject string much appreciated. I am trying to come up with a way to select something either an email message word a word document. Your point about sel is good I thought it was a select statement.
#11
I simply want to find the bookmark <<**>> that I have placed earlier in the text. That is my only object at the moment.
#12
How will you get whole text from Outlook message? Ctrl+A and Ctrl+C?
When you have text, use function find. It returns character position. Or can use findrx, if want to use regular expression. Or findw, to simply find whole word.
But then may be difficult or slow or impossible to highlight the text. If you need it.
#13
here is an example using function find and function get
it finds the text either before your bookmark or after your bookmark


;;finds whatever comes before <<**>>
str a="this is all the text before your bookmark<<**>>this is all the text after your bookmark"
int u=find(a "<<**>>")
a.get(a 0 u)
out a
;;
;finds whatever comes after <<**>>
str c="this is all the text before your bookmark<<**>>this is all the text after your bookmark"
int t=find(c "<<**>>")
str d=c.len
int x=val(d)
c.get(c (t+6) x)
out c
#14
Kevin
Thanks for the code to learn on. It works well and very understandable. However it does not accomplish what I need which is to search inside and email. It works well to search inside a pre-determined string. In fact it is great. But I just want to get to the book mark. And stop within the email where others things can be accomplished.
#15
How will you get whole text from Outlook message? Ctrl+A and Ctrl+C?
When you have text, use function find. It returns character position. Or can use findrx, if want to use regular expression. Or findw, to simply find whole word.

I am trying to come up with a way to look inside the text without using the find function in Outlook or in Word. I wanted to be able to open up a word document for instance and find <<**>> using findw or find. There are several of these "bookmarks", i.e. <<**>> and I wish to find one and stop and then another and stop. Seeing Kevin's example this might not be possible.
#16
it would help if you could tell us what version of Word and what version of outlook your using.Maybe can use Word Type Library.
#17
2010 for both.
#18
Windows 7
#19
check your type library list in QM and see if u have word or outlook listed
qm menu tools then Type Libraries...
If you do come back to the forum and do a search for word to see some examples of how it has been used.Keep in mind the syntax maybe slightly different for your version.
for more info on type libraries read qm help
#20
I rewrote your original and it now works in a limited sense in Word. That is a huge step forward to where I am going. Thank You.

First Macro
str+ g_sA
;CopyAll
key Ca ;; Ctrl+A
g_sA.getsel
key D ;; Down


Second Macro
str+ g_sA
str b=g_sA
int u=find(b "<<**>>")
b.get(b 0 u)
key "The Material Before First Bookmark: "
outp b

Third Macro
str+ g_sA
str b=g_sA
int t=find(b "<<**>>")
str d=b.len
int x=val(d)
b.get(b (t+6) x)
key "The Material After First Bookmark: "
outp b

In the second Macro is there a way to repeat until it no longer finds the bookmark <<**>>.

As for the TypeLib it might work but it takes me in a new direction. I will do some work in that error and get back.
#21
I did try rep which did not work
#22
Macro Macro1987
Code:
Copy      Help
out
str s="aaaaa <<**>> bbbbbbbbbb <<**>> cccccccc"
str sFind="<<**>>"
rep
,int u=find(s sFind u)
,if(u<0) break
,out "Found at %i: %s" u s+u
,u+sFind.len
#23
Thank you for the use of rep I am not sure of the symbol before the lines it looks like underline.

However my main question is using somewhat the same form of

str+ g_sA
str b=g_sA
int u=findw(b "<<**>>" 0 " .:\/''[]")
b.get(b 0 u)

How do I stop when the first instance of <<**>> is found?
#24
Do you really want to stop? or Pause? i am thinking you mean pause. But if u just want to stop don't use rep.I think your asking how do u perform actions with each time it is found. You will need to make a sel case syntax.
e.g.,
sel i
case 0
statements go here
case 1
statements go here
case 2
statements go here
etc, etc etc........
or
if u want to do different action on first time and the same for the rest after
sel i
case o
statements go here
case else
statements go here


example:
Function Function127
Code:
Copy      Help
out
str s=" aaaaa <<**>> bbbbbb bbbbb1 <<**>> cccccc ccccccc1 <<**>> aaaaaaaaaa2 <<**>> bbbbbbbbbb2 <<**>> cccccccc2 <<**>>"
str sFind="<<**>>"
str d sss ss=s
int i t tt x
rep
,int u=find(s sFind u)
,if(u<0) break
,sel i;;i is is a counter that u can use to have case statements to handle each instance of <<**>> found
,,case 0;;first instance of <<**>> found
,,sss.get(ss 0 u)
,,t=sss.len+6
,,out sss
,,;To Do
,,;insert code  here to do after after first instanceof <<**>> is found and text has been extracted
,,;note this will not stop the rep. just allows you to do something with the data
,,
,,
,,
,,case else;;any other time <<**>> is found accept first time
,,x=u-t
,,sss.get(ss t x)
,,t=u+6
,,out sss    
,,;To Do
,,;insert code  here to do after after 2nd or > instance of <<**>> is found and text has been extracted
,,
,,
,,
,u+sFind.len
,i+1
also are you sure your delimiters are correct in your findw statement?
#25
jnicholsadams Wrote:I am not sure of the symbol before the lines it looks like underline.
the symbols before each line are commas,they are tab indentions for the code.
Tip
just copy the code in the code box as it is and paste it in a new function or macro in qm then in the Qm output you will see
Click here to correct the pasted code
click that and Qm will place the code as it is was originally written.(e.g.,add the tab indentions back)
to show your code here in the forum from qm-
select the code in qm editor, right click in the editor and in the popup menu find other formats> copy for qm forum.
then just paste your code here.
#26
Kevin.
So you need a comma to note the whole of the rep statement I assume.

The sel example is good but not something I can use since I can quite make it fit. I don't see who to put in a findw or find statement.

Your bit of code you sent second was much closer. A wonderful piece of code which I almost understand. I will work with it and come back in a few days.
Thanks for all your help. Sorry to be so dumb.
#27
Kevin
I meant to ask in the last note why an
out
at the beginning. I looked in the reference in it was not there.
I have used annotations to try and figure things out as I always do.
#28
the "out" at the beginning clears the QM output window.You can delete it if u like
the commas show up here cause it is a special format for the forum,not QM script format.when writing code in the QM editor there are no commas.let me try and explain .
take for example Gintaras code example

if u made it yourself in qm would look like the picture below
QM editor code
the comma represents hitting the tab key once in qm or the spacebar 4 times
it's called tab-indention.
the commas show up here so when u copy the code from the forum and u paste into qm editor qm can adjust the code back to the QM format.
Certain functions require this tab-indention qm does this automatically as u are coding
try it yourself
in qm editor type rep and hit enter and you will see what i am talking about


Attached Files Image(s)
   
#29
Thanks for explanation

I can not make the following work:
out
key Ca ;; Ctrl+A
g_sA.getsel
key X ;; Delete
str+ g_sA g_sB g_sC
str s=g_sA
str g_sB=g_sA
str sFind="<<**>>"
str d sss ss=s
str news="email"
str news1="name"
int i t tt x
rep
,int u=find(s sFind u)
,if(u<0) break
,sel i;;i is is a counter that u can use to have case statements to handle each instance of <<**>> found
,,case 0;;first instance of <<**>> found
,,sss.get(ss 0 u)
,,t=sss.len+6
,,outp news
,,outp sss
,,key Y
,,case 1;;second instance of <<**>> found
,,sss.get(ss 1 u)
,,t=u+6
,,outp news1
,,outp sss
,,
,,;To Do
,,;insert code here to do after after first instanceof <<**>> is found and text has been extracted
,,;note this will not stop the rep. just allows you to do something with the data
,,
,,
,,
,,case else;;any other time <<**>> is found accept first time
,,x=u-t
,,sss.get(ss t x)
,,t=u+6
,,outp sss
,,,,;To Do
,,;insert code here to do after after 2nd or > instance of <<**>> is found and text has been extracted
,,
,,
,,
,u+sFind.len
,i+1
#30
OK well u didn't follow my example u change some things
case 1;;second instance of <<**>> found
sss.get(ss 1 u)
that is incorrect why did u change this?
if u want to get the "second instance of <<**>> found" use
,,case 1;;second instance of <<**>> found or ;;any other time <<**>> is found accept case 0
,,x=u-t
,,sss.get(ss t x)
,,t=u+6
WHY are u using outp are u pasting into another file?
if u are make sure u activate that window before pasting
if not just use out to see results in qm output


Forum Jump:


Users browsing this thread: 1 Guest(s)