Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combine variables
#1

Is it possible to combine string and integer into one? I'm trying to combine words with numbers, but when I tried .from, I was recieving random number and letters. So I tried combining the integers together first and then just adding the 1 string and 1 integer together, but when using string it doesn't give what i'm trying to receive.


Macro ( Macro38 )
Code:
Copy      Help
int i d p;str q
i=1
d=2
p=(i+d)

q="You have"
str a=(q+p)
out a


Output box:

have

What i'm trying to get:

You have 3
Taking on Quick Macros one day at a time
#2

Nevermind, I just figured it out.


Macro ( Macro38 )
Code:
Copy      Help
int i d p;str q w
i=1
d=2
p=(i+d)
w=p

q="You have "
str a.from(q w)
out a


I hate brainfarts! :?
Taking on Quick Macros one day at a time
#3
Code:
Copy      Help
int i d p;str q
i=1
d=2
p=(i+d)

q="You have"
str a.from(q " " i)
out a
a.format("You have %i" i)
out a
a.format("%s %i" q i)
out a
pi
#4

In response to this, why would this not insert multiple line information into dialog editbox? For some reason it just replaces the previous information inserted, rather then multiple lines of information?
Taking on Quick Macros one day at a time
#5
because content of string a is always overwritten.
use froma or formata to add lines to a.
Code:
Copy      Help
int i d p;str q
i=1
d=2
p=(i+d)

q="You have"
str a.from(q " " i "[]")
out a
a.formata("You have %i[]" i)
out a
a.formata("%s %i[]" q i)
out a

[] means linebreak
pi
#6

I know that, i'm trying to solve QM EXPERT's question from one of his other posts, but when inserting it into an editbox inside a dialog, it just keeps inserting the information over the top of the previous information that was inserted.

The dialog that he has grabs the root, then a starting number and an ending number; Root=1, Start=1, End=5, and what this does is output: 11 12 13 14 15. So i'm trying to transfer the information from the dialog that gets this information to another dialog which will paste the information into an editbox. I have everything working until it inserts the information from the first dialog. It grabs the information but then when it pastes the information it overwrites the previous line. Which results in only showing the last number; 15.
Taking on Quick Macros one day at a time
#7
use either a global or thread variable.
pi
#8

I did. Still doesnt work right. Here's the 2 dialogs. Maybe this will help.


Function ( Number_Dialog ) Trigger ( S1 )
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 209 55 "Number Dialog"
;2 Button 0x54030000 0x4 150 12 56 32 "CLOSE"
;3 Edit 0x54032000 0x200 56 20 32 14 ""
;4 Edit 0x54032000 0x200 56 36 32 14 ""
;5 Static 0x54000000 0x0 2 22 52 10 "Starting Number"
;6 Static 0x54000000 0x0 4 40 50 8 "Ending Number"
;7 Button 0x54032000 0x0 90 12 56 32 "GRAB"
;8 Edit 0x54030080 0x200 30 4 58 14 ""
;9 Static 0x54000000 0x0 8 8 18 8 "Root"
;END DIALOG
;DIALOG EDITOR: "" 0x2020102 "" "" ""


str controls = "3 4 8"
str e3 e4 e8
if(!ShowDialog("Number_Dialog" &Number_Dialog &controls)) ret



ret
;messages
if(message=WM_INITDIALOG) DT_Init(hDlg lParam)
;int param=DT_GetParam(hDlg)

sel message
,case WM_INITDIALOG
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 7 ;;Grab
,int+ i a b c; str+ d s s1 s2 s3
,s.getwintext(id(3 hDlg)); a=val(s)
,s.getwintext(id(4 hDlg)); b=val(s)
,d.getwintext(id(8 hDlg))
,for i a b+1
,,mac- "Other_Dialog"

,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1




Function ( Other_Dialog ) Trigger ( S2 )
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;4 Button 0x54032000 0x0 68 82 72 14 "Insert Information"
;3 Edit 0x54230844 0x20000 26 18 156 60 ""
;5 Button 0x54020007 0x0 20 10 168 90 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020102 "" "" ""



str controls = "3"
str e3
if(!ShowDialog("Other_Dialog" &Other_Dialog &controls)) ret



ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4 ;;Insert Information
,int+ i a b c; str+ d s
,for i a b+1
,,s.from(d i "[]")
,,s.setwintext(id(3 hDlg))
,
,case IDOK
,case IDCANCEL
ret 1
Taking on Quick Macros one day at a time
#9
You know getwintext, setwintext and adding strings. Then what is the problem?

s.getwintext(id(x hDlg))
s+"[]"
s+i
s.setwintext(id(x hDlg))
#10

Yep, i'm an idiot. I'm just thinking too hard. Thanks.
Taking on Quick Macros one day at a time
#11
QM Assistant Wrote:
Yep, i'm an idiot.
welcome in the club.
:roll:
pi
#12

Is there any way to avoid the macro adding the end number to the beginning before it adds them all?

When I try it, I get:

5Numbers1
Numbers2
Numbers3
Numbers4
Numbers5

Any ideas why? Why do I have a feeling the answer is right in front of my eyes, but i'm just not seeing it. :?
Taking on Quick Macros one day at a time


Forum Jump:


Users browsing this thread: 2 Guest(s)