Page 1 of 1

Type Editor

Posted: Tue Sep 05, 2006 6:37 pm
by Guimauve
Hello everyone.

mskuma have asked me about the tool I use to generate a code to manipulate Structures.

I think it's the time for public release. The program are currently in Version 0.4.7 Beta but generate the code very well. So for the moment use it at your own risk.

This version come with the French/English GUI, the French help file (5% completed) and English help file (0.5% completed). (Sorry about that)
Just load the supplied exemples to see how to use the program. When the program reach Version 1.0.0 all help and tutorial file will be supplied.

How to install ? Just unzip file in your favorite folder. If you want to uninstall just delete the folder were you have unzipped the program.
File:1->Type_Editor.zip
Image

[EDIT] A new version , this new one will not use 100% CPU.

Regards
Guimauve

Posted: Tue Sep 05, 2006 7:04 pm
by Trond
It uses 100% cpu.

Posted: Wed Sep 06, 2006 3:25 pm
by Guimauve
1 day, 1 download :(

For those want more information about my tool please read this.

You create a program and you want to Store some information in a Preferences file and you want to use a Structure to manage these information. Your structure look like this :

Code: Select all

Structure UserPref

   FileName.s
   Language.s
   PositionX.l
   PositionY.l
   Width.l
   Height.l
   SavePath.s

EndStructure
Now you will have to create an interface between this structure and the PB Preferences command to create your file. It's a little bit long to do.

For a Structure like this, my small tool can do the job for you in less than a second. On my computer 0.047 seconds.

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; AUTOMATICALLY GENERATED CODE, DO NOT MODIFY
; UNLESS YOU REALLY, REALLY, REALLY MEAN IT !!
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Code generated by : Type Editor
; Project name : the project name here
; File name : File name here
; File Version : 0.0.0
; Programmation : To verify
; Programmed by : Your name here
; AKA : Your NickName here
; E-mail : address@something.com
; Creation Date : 06-09-2006
; Last update : 06-09-2006
; Coded for PureBasic V4.00
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Structure declaration >>>>>

Structure UserPref

   FileName.s
   Language.s
   PositionX.l
   PositionY.l
   Width.l
   Height.l
   SavePath.s

EndStructure

; <<<<<<<<<<<<<<<<<<<<
; <<<<< Mutators >>>>>

Macro SetUserPrefFileName(ObjectA, P_FileName)

   ObjectA\FileName = P_FileName

EndMacro

Macro SetUserPrefLanguage(ObjectA, P_Language)

   ObjectA\Language = P_Language

EndMacro

Macro SetUserPrefPositionX(ObjectA, P_PositionX)

   ObjectA\PositionX = P_PositionX

EndMacro

Macro SetUserPrefPositionY(ObjectA, P_PositionY)

   ObjectA\PositionY = P_PositionY

EndMacro

Macro SetUserPrefWidth(ObjectA, P_Width)

   ObjectA\Width = P_Width

EndMacro

Macro SetUserPrefHeight(ObjectA, P_Height)

   ObjectA\Height = P_Height

EndMacro

Macro SetUserPrefSavePath(ObjectA, P_SavePath)

   ObjectA\SavePath = P_SavePath

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Observators >>>>>

Macro GetUserPrefFileName(ObjectA)

   ObjectA\FileName

EndMacro

Macro GetUserPrefLanguage(ObjectA)

   ObjectA\Language

EndMacro

Macro GetUserPrefPositionX(ObjectA)

   ObjectA\PositionX

EndMacro

Macro GetUserPrefPositionY(ObjectA)

   ObjectA\PositionY

EndMacro

Macro GetUserPrefWidth(ObjectA)

   ObjectA\Width

EndMacro

Macro GetUserPrefHeight(ObjectA)

   ObjectA\Height

EndMacro

Macro GetUserPrefSavePath(ObjectA)

   ObjectA\SavePath

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Open Preferences file >>>>>

Procedure OpenUserPrefPreferences(*ObjectA.UserPref)

   If OpenPreferences(GetUserPrefFileName(*ObjectA))

      SetUserPrefLanguage(*ObjectA, ReadPreferenceString("Language", GetUserPrefLanguage(*ObjectA)))
      SetUserPrefPositionX(*ObjectA, ReadPreferenceLong("PositionX", GetUserPrefPositionX(*ObjectA)))
      SetUserPrefPositionY(*ObjectA, ReadPreferenceLong("PositionY", GetUserPrefPositionY(*ObjectA)))
      SetUserPrefWidth(*ObjectA, ReadPreferenceLong("Width", GetUserPrefWidth(*ObjectA)))
      SetUserPrefHeight(*ObjectA, ReadPreferenceLong("Height", GetUserPrefHeight(*ObjectA)))
      SetUserPrefSavePath(*ObjectA, ReadPreferenceString("SavePath", GetUserPrefSavePath(*ObjectA)))

      ClosePreferences()

   EndIf

EndProcedure

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Create Preferences file >>>>>

Procedure CreateUserPrefPreferences(*ObjectA.UserPref)

   If CreatePreferences(GetUserPrefFileName(*ObjectA))

      WritePreferenceString("Language", GetUserPrefLanguage(*ObjectA))
      WritePreferenceLong("PositionX", GetUserPrefPositionX(*ObjectA))
      WritePreferenceLong("PositionY", GetUserPrefPositionY(*ObjectA))
      WritePreferenceLong("Width", GetUserPrefWidth(*ObjectA))
      WritePreferenceLong("Height", GetUserPrefHeight(*ObjectA))
      WritePreferenceString("SavePath", GetUserPrefSavePath(*ObjectA))

      ClosePreferences()

   EndIf

EndProcedure

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code generated in : 47 ms <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
You just need to save and include this source to your program then Set the default value to the structure.

In your program you just need to call OpenUserPrefPreferences(*ObjectA.UserPref) and
CreateUserPrefPreferences(*ObjectA.UserPref) with your structured variable and that it.

You need to store the Entity direction in your game project and you would like to use a Structure to keep these information. Your Structure look like this :

Code: Select all

Structure Vector3D

   Coords.f[2] ; i, j, k

EndStructure
Once again with my program you can write many basic operator to manipulate your structure in less than a second. With my computer 0.078 seconds.

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; AUTOMATICALLY GENERATED CODE, DO NOT MODIFY
; UNLESS YOU REALLY, REALLY, REALLY MEAN IT !!
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Code generated by : Type Editor
; Project name : the project name here
; File name : File name here
; File Version : 0.0.0
; Programmation : To verify
; Programmed by : Your name here
; AKA : Your NickName here
; E-mail : address@something.com
; Creation Date : 06-09-2006
; Last update : 06-09-2006
; Coded for PureBasic V4.00
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Structure declaration >>>>>

Structure Vector3D

   Coords.f[3] ; i, j, k

EndStructure

; <<<<<<<<<<<<<<<<<<<<
; <<<<< Mutators >>>>>

Macro SetVector3DCoords(MyVectorA, Index, P_Coords)

   MyVectorA\Coords[Index] = P_Coords

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Observators >>>>>

Macro GetVector3DCoords(MyVectorA, Index)

   MyVectorA\Coords[Index]

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Specials mutators >>>>>

Macro SetVector3Di(MyVectorA, P_i)

   SetVector3DCoords(MyVectorA, 0, P_i)

EndMacro

Macro SetVector3Dj(MyVectorA, P_j)

   SetVector3DCoords(MyVectorA, 1, P_j)

EndMacro

Macro SetVector3Dk(MyVectorA, P_k)

   SetVector3DCoords(MyVectorA, 2, P_k)

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Specials observators >>>>>

Macro GetVector3Di(MyVectorA)

   GetVector3DCoords(MyVectorA, 0)

EndMacro

Macro GetVector3Dj(MyVectorA)

   GetVector3DCoords(MyVectorA, 1)

EndMacro

Macro GetVector3Dk(MyVectorA)

   GetVector3DCoords(MyVectorA, 2)

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Update static array >>>>>

Macro UpdateVector3DCoords(MyVectorA, P_i, P_j, P_k)

   SetVector3DCoords(MyVectorA, 0, P_i)
   SetVector3DCoords(MyVectorA, 1, P_j)
   SetVector3DCoords(MyVectorA, 2, P_k)

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Equal operator >>>>>

Macro EqualVector3D(MyVectorA, MyVectorB)

   For Index = 0 To 2
      SetVector3DCoords(MyVectorA, Index, GetVector3DCoords(MyVectorB, Index))
   Next

   ; CopyMemory(MyVectorB, MyVectorA, SizeOf(Vector3D))

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Plus operator >>>>>

Macro PlusVector3D(MyVectorA, MyVectorB, MyVectorR)

   For Index = 0 To 2
      SetVector3DCoords(MyVectorR, Index, GetVector3DCoords(MyVectorA, Index) + GetVector3DCoords(MyVectorB, Index))
   Next

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Minus operator >>>>>

Macro MinusVector3D(MyVectorA, MyVectorB, MyVectorR)

   For Index = 0 To 2
      SetVector3DCoords(MyVectorR, Index, GetVector3DCoords(MyVectorA, Index) - GetVector3DCoords(MyVectorB, Index))
   Next

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< ProductByScalar operator >>>>>

Macro ProductByScalarVector3D(Scalar, MyVectorA, MyVectorR)

   For Index = 0 To 2
      SetVector3DCoords(MyVectorR, Index, GetVector3DCoords(MyVectorA, Index) * Scalar)
   Next

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< DivideByScalar operator >>>>>

Macro DivideByScalarVector3D(Scalar, MyVectorA, MyVectorR)

   For Index = 0 To 2
      SetVector3DCoords(MyVectorR, Index, GetVector3DCoords(MyVectorA, Index) / Scalar)
   Next

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Zero operator >>>>>

Macro ZeroVector3D(MyVectorA)

   For Index = 0 To 2
      SetVector3DCoords(MyVectorA, Index, 0)
   Next

   ; RtlZeroMemory_(MyVectorA, SizeOf(Vector3D))

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< ResetALL operator >>>>>

Macro ResetVector3DAll(MyVectorA)

   For Index = 0 To 2
      SetVector3DCoords(MyVectorA, Index, 0)
   Next

   ; RtlZeroMemory_(MyVectorA, SizeOf(Vector3D))

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Copy operator >>>>>

Macro CopyVector3D(MyVectorA, MyVectorB)

   For Index = 0 To 2
      SetVector3DCoords(MyVectorB, Index, GetVector3DCoords(MyVectorA, Index))
   Next

   ; CopyMemory(MyVectorA, MyVectorB, SizeOf(Vector3D))

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Compare operator >>>>>

ProcedureDLL.b CompareVector3D(*MyVectorA.Vector3D, *MyVectorB.Vector3D)

   Compare.b = #True

   For Index = 0 To 2
      If GetVector3DCoords(*MyVectorA, Index) <> GetVector3DCoords(*MyVectorB, Index)
         Compare = #False
         Break
      EndIf
   Next

   ProcedureReturn Compare

EndProcedure

; Macro CompareVector3D(MyVectorA, MyVectorB)
   ; CompareMemory(MyVectorA, MyVectorB, SizeOf(Vector3D))
; EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Read Preference Group >>>>>

ProcedureDLL ReadPreferenceVector3D(GroupName.s, *MyVectorA.Vector3D)

   PreferenceGroup(GroupName)

   For Index = 0 To 2
      SetVector3DCoords(*MyVectorA, Index, ReadPreferenceFloat("Coords" + Str(Index), GetVector3DCoords(*MyVectorA, Index)))
   Next

EndProcedure

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Write Preference Group >>>>>

ProcedureDLL WritePreferenceVector3D(GroupName.s, *MyVectorA.Vector3D)

   PreferenceGroup(GroupName)

   For Index = 0 To 2
      WritePreferenceFloat("Coords" + Str(Index), GetVector3DCoords(*MyVectorA, Index))
   Next

EndProcedure

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Read binary file >>>>>

ProcedureDLL ReadVector3D(FileID.l, *MyVectorA.Vector3D)

   For Index = 0 To 2
      SetVector3DCoords(*MyVectorA, Index, ReadFloat(FileID))
   Next

EndProcedure

; Macro ReadVector3D(FileID, MyVectorA)
   ; ReadData(FileID, MyVectorA, SizeOf(Vector3D))
; EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Write binary file >>>>>

ProcedureDLL WriteVector3D(FileID.l, *MyVectorA.Vector3D)

   For Index = 0 To 2
      WriteFloat(FileID, GetVector3DCoords(*MyVectorA, Index))
   Next

EndProcedure

; Macro WriteVector3D(FileID, MyVectorA)
   ; WriteData(FileID, MyVectorA, SizeOf(Vector3D))
; EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Debug Macro >>>>>

Macro DebugVector3D(MyVectorA)

   For Index = 0 To 2
      Debug GetVector3DCoords(MyVectorA, Index)
   Next

EndMacro

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Code generated in : 78 ms <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
You just need to Fine tune the code and add all missing stuff.

Your question is : Why I will waste my time to hide the structure access path inside a macro instead of just write it directly ?

For exemple in your program you have 4 differents structures :

Code: Select all

Structure Star3D
  
  PosX.w
  PosY.w
  PosZ.w
  Speed.w
  
EndStructure

Structure Square2D
  
  PosX.w
  PosY.w
  Width.w
  Height.w
  Color.l
  
EndStructure

Structure Spot
  
  PosX.w
  PosY.w
  Radius.w
  Color.l
  
EndStructure

Structure Indicator
  
  PosX.w
  PosY.w
  Text.s
  Color.l
  
EndStructure
After several weeks of programming you need to modify the Star3D structure like this :

Code: Select all

Structure Star3D
  
  PositionX.w
  PositionY.w
  PositionZ.w
  Speed.w
  
EndStructure
In your code you have used all 4 structures in the same code but you are distracted by your girlfriend and you modifiy your code by selecting all of your code (Ctrl +A) and Find/Replace "\Pos" by "\Position".

Image

And you have a choice
Image
Alone in front of your computer or
Image
your grilfriend.

http://smiley-gratuit.eu/

So by hiding the structure access path inside macro you Find/Replace will replace the Macro "Star3DPos" by "Star3DPosition". That way only the Star3D will be modified.

It is much faster ? I think YES. Don't you ?

This is the main reason why I have develloped this tool.

Regards
Guimauve

Posted: Wed Sep 06, 2006 3:28 pm
by Dare
:D

Love the smileys.

Haven't got into your app - yet!

Posted: Thu Sep 07, 2006 1:46 am
by mskuma
Very interesting app with good design. Guimauve, check your mail. I updated the English lang file since there was a minor corruption regarding the P_ prefix bit.

Posted: Thu Sep 07, 2006 2:06 am
by Guimauve
This small problem, "P_ prefix", as been corrected but I have not uploaded the new version yet. Anyway this small error is not critical. By the way the program generate the French\English file only if it not exist, so if you correct this error in the english text file you will be ok until the next release.

For the moment, the code Style is Based Object Programming.
As soon as the program reach Version 1.0.0, I will add the Oriented Object Programming style with the Structure, Interface, VTable, etc. It's not very difficult to add this feature.

Special Thanks to everyone for your time.

Regards
Guimauve