Page 1 of 1

one question that happens in x86 but not in x64(pb5&4.61)

Posted: Thu Jan 31, 2013 5:36 am
by ynkrc
I want to skin for window and found a question that happens in x86 but not in x64(pb5&4.61)
then Streamline the codes to below(error on line 48)

Code: Select all

Structure imgInfo
  ImgFromRect.rect
  ImgDrawRect.rect
  DrawOrNot.l
EndStructure

Structure Buttons
  ImgUrl.s
  ImgID.l
  ImgMouseOn.imgInfo
  ImgMouseOut.imgInfo
  ImgMouseDown.imageInfo
EndStructure

Structure skinInfo
  GlobalSkinImageID.l
  CloseButton.Buttons
  MaxButton.Buttons
  NomalButton.Buttons
  MinButton.Buttons
EndStructure

Global skin.skinInfo


Procedure getRectFromStr(Str.s,*rc.rect)
  If CountString(str,",")=3
    *rc\left=Val(StringField(str,1,","))
    *rc\top=Val(StringField(str,2,","))
    *rc\right=Val(StringField(str,3,","))
    *rc\bottom=Val(StringField(str,4,","))
  EndIf
  ProcedureReturn #True
EndProcedure
Procedure getImgInfoFromStr(Str.s,*ii.imgInfo)
  If CountString(str,"#")=2
    getRectFromStr(StringField(str,1,"#"),*ii\ImgFromRect)
    getRectFromStr(StringField(str,2,"#"),*ii\ImgDrawRect)
    *ii\DrawOrNot=Val(StringField(str,3,"#"))
  EndIf
EndProcedure
Procedure getButtonsFromStr(str.s,*bs.Buttons,imgId.l=0)
  If CountString(str,"|")=3
    getImgInfoFromStr(StringField(str,1,"|"),*bs\ImgMouseOut)
    getImgInfoFromStr(StringField(str,2,"|"),*bs\ImgMouseOn)
    getImgInfoFromStr(StringField(str,3,"|"),*bs\ImgMouseDown)
    temp.s=StringField(str,4,"|")
    *bs\ImgUrl=temp
  EndIf
EndProcedure

Procedure getSkinInfo(*sk.SkinInfo)
  getButtonsFromStr("144,1,180,18#-38,1,37,17#1|144,19,180,36#-38,1,37,17#1|144,37,180,54#-38,1,37,17#1|",*sk\CloseButton,*sk\GlobalSkinImageID)
  getButtonsFromStr("144,1,180,18#-38,1,37,17#1|144,19,180,36#-38,1,37,17#1|144,37,180,54#-38,1,37,17#1|",*sk\NomalButton,*sk\GlobalSkinImageID)
  getButtonsFromStr("144,1,180,18#-38,1,37,17#1|144,19,180,36#-38,1,37,17#1|144,37,180,54#-38,1,37,17#1|",*sk\MaxButton,*sk\GlobalSkinImageID)
  getButtonsFromStr("144,1,180,18#-38,1,37,17#1|144,19,180,36#-38,1,37,17#1|144,37,180,54#-38,1,37,17#1|",*sk\MinButton,*sk\GlobalSkinImageID)
EndProcedure

getSkinInfo(skin)

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 7:49 am
by ynkrc
I have tested and found that
the value of "@*bs\imgUrl" have different values when the fourth Four calls
It occurs error on the third call,and
the value of "@*bs\imgUrl" in three calls are 0,0,1
It sames very strange!
:!:

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 8:06 am
by Little John
Please do not post coding questions in the bug forum, and do not post the same question in multiple subforums :!:
(Also, any new topic should get a meaningful title.)
Thanks.

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 8:17 am
by ynkrc
Little John wrote:Please do not post coding questions in the bug forum, and do not post the same question in multiple subforums :!:
Thanks.
oh,I am sorry ,but I had shared my code with several pber and found without Syntax error,So I thought it may be a bug,then posted the codes in the bug area wanting to make the Purebasic more and more perfect.
if you think it's not a bug,could you please tell me why the error occurs?

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 8:38 am
by ynkrc
Little John wrote:Please do not post coding questions in the bug forum, and do not post the same question in multiple subforums :!:
(Also, any new topic should get a meaningful title.)
Thanks.
I have found a interesting way to solve the question:
change the position of line imgUrl.s like this then no error will occur.(not the first and not the last)

Code: Select all

Structure Buttons
  ImgID.l
  ImgMouseOn.imgInfo
  ImgMouseOut.imgInfo
  ImgUrl.s
  ImgMouseDown.imageInfo
EndStructure
But I don't know Why!
Could Somebody Tell Me? :(

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 8:45 am
by Rings
moved...

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 8:46 am
by ynkrc
Rings wrote:moved...
....
moved?What does it mean?

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 9:30 am
by Salc
If you use the right structure in buttons it should work.

Code: Select all

Structure Buttons
  ImgUrl.s
  ImgID.l
  ImgMouseOn.imgInfo
  ImgMouseOut.imgInfo
  ImgMouseDown.imageInfo   ;<-- This makes the problem, change it to imgInfo
EndStructure

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 10:39 am
by Little John
if you think it's not a bug,could you please tell me why the error occurs?
Define varaibles for your structures. Pass the variable names to the respective procedures, NOT pointers. (I.e. * at the beginning is only OK here for the parameters in the procedure definition.) Use EnableExplicit at the beginning of the code, it will help you to locate problems of this kind. Maybe you also want to read in the help about pointers and structures, and how to pass them to procedures.

Code: Select all

; WRONG

Structure foo
   demo.i
EndStructure

Procedure test (*a.foo)
   *a\demo = 10
   Debug *a\demo
EndProcedure

test(*bar.foo)

Code: Select all

; CORRECT

Structure foo
   demo.i
EndStructure

Procedure test (*a.foo)
   *a\demo = 10
   Debug *a\demo
EndProcedure


Define bar.foo
test(bar)
Regards, Little John

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 12:46 pm
by ynkrc
Salc wrote:If you use the right structure in buttons it should work.

Code: Select all

Structure Buttons
  ImgUrl.s
  ImgID.l
  ImgMouseOn.imgInfo
  ImgMouseOut.imgInfo
  ImgMouseDown.imageInfo   ;<-- This makes the problem, change it to imgInfo
EndStructure
Oh!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!MyGod!

Re: one question that happens in x86 but not in x64(pb5&4.61

Posted: Thu Jan 31, 2013 1:00 pm
by buddymatkona
@ynkrc
Normally if you mistype the name of a structure, PB will let you know however, you made a very unlucky typo. :)
Run this by itself:

Code: Select all

EnableExplicit

  CompilerIf Defined(SomeTypo, #PB_Structure)
    Debug "Structure 'SomeTypo' is already declared"
  CompilerElse
     Debug "Structure 'SomeTypo' is not recognized"
  CompilerEndIf
  
  CompilerIf Defined(ImageInfo, #PB_Structure)
    Debug "Structure 'ImageInfo' is already declared"
  CompilerElse
     Debug "Structure 'ImageInfo' is not recognized"
  CompilerEndIf