Devide/calculate a value
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 68
- Joined: Wed Dec 07, 2005 7:13 am
Devide/calculate a value
This should be simple, but I keep failing to get out a simple math result:
Let>ImageFile=test.jpg
Dialog>ImageSizeDialog
object ImageSizeDialog: TForm
object MSImage1: tMSImage
AutoSize = True
end
end
EndDialog>ImageSizeDialog
SetDialogProperty>ImageSizeDialog,MSImage1,LoadImage,Imagefile
GetDialogProperty>ImageSizeDialog,MSImage1,Width,Xpixels
GetDialogProperty>ImageSizeDialog,MSImage1,Height,Ypixels
Let>x=xpixels/20,48
Let>y=ypixels/20,65
WriteLN>c:\test\x.txt,result,x
WriteLN>c:\test\y.txt,result,y
I had expected to have a result n devided by 20,48 in the x-file, but instead of the result, I receive a text "n/20,48" in the x.txt file (same in the y,txt). So calculations do not work in the WriteLN command? And how would one fix it?
Let>ImageFile=test.jpg
Dialog>ImageSizeDialog
object ImageSizeDialog: TForm
object MSImage1: tMSImage
AutoSize = True
end
end
EndDialog>ImageSizeDialog
SetDialogProperty>ImageSizeDialog,MSImage1,LoadImage,Imagefile
GetDialogProperty>ImageSizeDialog,MSImage1,Width,Xpixels
GetDialogProperty>ImageSizeDialog,MSImage1,Height,Ypixels
Let>x=xpixels/20,48
Let>y=ypixels/20,65
WriteLN>c:\test\x.txt,result,x
WriteLN>c:\test\y.txt,result,y
I had expected to have a result n devided by 20,48 in the x-file, but instead of the result, I receive a text "n/20,48" in the x.txt file (same in the y,txt). So calculations do not work in the WriteLN command? And how would one fix it?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Devide/calculate a value
Let>x=xpixels/20.48
Let>y=ypixels/20.65
Let>y=ypixels/20.65
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 68
- Joined: Wed Dec 07, 2005 7:13 am
Re: Devide/calculate a value
Thanks -:-)
But why does this one say "can not read string as float"?
The example in the help goes like this:
Let>decimal=34.6
Let>rounded={round(%decimal%)}
My code is:
Let>x=xpixels/20.48
Let>y=ypixels/20.65
Let>rounded={round(%x%)}
Let>rounded={round(%y%)}
I left out the "%" and it complained, it would not find the identifier "x". So what is wrong and just why?
But why does this one say "can not read string as float"?
The example in the help goes like this:
Let>decimal=34.6
Let>rounded={round(%decimal%)}
My code is:
Let>x=xpixels/20.48
Let>y=ypixels/20.65
Let>rounded={round(%x%)}
Let>rounded={round(%y%)}
I left out the "%" and it complained, it would not find the identifier "x". So what is wrong and just why?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Devide/calculate a value
I'm not replicating (assuming I set xpixels and ypixels to something).
What are xpixels and ypixels set to in your case?
Does this lone macro work:
What are xpixels and ypixels set to in your case?
Does this lone macro work:
Code: Select all
Let>decimal=34.6
Let>rounded={round(%decimal%)}
Let>xpixels=100
Let>ypixels=150
My code is:
Let>x=xpixels/20.48
Let>y=ypixels/20.65
Let>rounded={round(%x%)}
Let>rounded={round(%y%)}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 68
- Joined: Wed Dec 07, 2005 7:13 am
Re: Devide/calculate a value
It seems this way works:
Let>x=xpixels/20.48
Let>y=ypixels/20.65
SetRoundMode>0
Let>x={Round(%x%)}
Let>y={Round(%y%)}
WriteLN>c:\test\x.txt,result,x
WriteLN>c:\test\y.txt,result,y
WriteLN>c:\test\z.txt,result,1,5
I could not test thoroughly, though. But the first results look promising. Since this has to work within a larger context, it will take some more days, before I have done all the the tests, I (or other users) would want to be done.
Let>x=xpixels/20.48
Let>y=ypixels/20.65
SetRoundMode>0
Let>x={Round(%x%)}
Let>y={Round(%y%)}
WriteLN>c:\test\x.txt,result,x
WriteLN>c:\test\y.txt,result,y
WriteLN>c:\test\z.txt,result,1,5
I could not test thoroughly, though. But the first results look promising. Since this has to work within a larger context, it will take some more days, before I have done all the the tests, I (or other users) would want to be done.
-
- Pro Scripter
- Posts: 68
- Joined: Wed Dec 07, 2005 7:13 am
Re: Devide/calculate a value
Sorry to return so late - no nothing works.
Even in your example it complains about line 11 and invalid parameters.
I am lost ....
Even in your example it complains about line 11 and invalid parameters.
I am lost ....
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Devide/calculate a value
Line 11? My example has 9 lines. Can you clarify which example and which line?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 68
- Joined: Wed Dec 07, 2005 7:13 am
Re: Devide/calculate a value
This is the complete code, in here it complains about line 21 and 22. Invalid parameters to round.
But shouldn`t it have all?
But shouldn`t it have all?
Code: Select all
Let>ImageFile=test.jpg
Dialog>ImageSizeDialog
object ImageSizeDialog: TForm
object MSImage1: tMSImage
AutoSize = True
end
end
EndDialog>ImageSizeDialog
SetDialogProperty>ImageSizeDialog,MSImage1,LoadImage,Imagefile
GetDialogProperty>ImageSizeDialog,MSImage1,Width,Xpixels
GetDialogProperty>ImageSizeDialog,MSImage1,Height,Ypixels
Let>x=xpixels/20.48
Let>y=ypixels/20.65
Let>decimal=34.6
Let>rounded={round(%decimal%)}
Let>xpixels=100
Let>ypixels=150
SetRoundMode>0
Let>x={Round(%x%)}
Let>y={Round(%y%)}
WriteLN>c:\test\x.txt,result,x
WriteLN>c:\test\y.txt,result,y
WriteLN>c:\test\z.txt,result,1,5
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Devide/calculate a value
Huh? Line 21 and 22 are these:
WriteLN>c:\test\x.txt,result,x
WriteLN>c:\test\y.txt,result,y
Your code works fine for me.
WriteLN>c:\test\x.txt,result,x
WriteLN>c:\test\y.txt,result,y
Your code works fine for me.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 68
- Joined: Wed Dec 07, 2005 7:13 am
Re: Devide/calculate a value
That is because I had excluded the text lines on top. So these are the lines it complains about, if I try to run it in the editor, but it works fine, once it is compiled.
Let>x={Round(%x%)}
Let>y={Round(%y%)}
So, problem solved.
Let>x={Round(%x%)}
Let>y={Round(%y%)}
So, problem solved.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Devide/calculate a value
Really? Are you sure you are running from the top when you run in the editor. Remember - the editor is a debugger. You may be executing from part way through the script before x and y have been set.if I try to run it in the editor, but it works fine, once it is compiled.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 68
- Joined: Wed Dec 07, 2005 7:13 am
Re: Devide/calculate a value
And that solved it all ...
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Devide/calculate a value
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?