elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Temas
Páginas: 1 2 [3] 4 5 6 7 8 9 10 11 12 13 14
21  Foros Generales / Foro Libre / [Consulta] Calculo vectorial... en: 21 Septiembre 2011, 07:55 am
.
Que significa la nAB   se que AB es la dirreccion de un vector es decir que va desde A hasta B pero no se que demonios significa esa n.

Dicha n aparece en la formula para saber el area de un triangulo respecto a vertices (Es una variante para hayar el area).


Esta duda la pongo por que mi profesora se a equivocado tremendamente en un ejercicio y bueno para exponerselo nesesito saber que es esa maldita n.

Es decir se que puedo hayar la distancia entre dos punto y asi aplicar la formula de:

AreaTriangulo = Lado1 * Lado2 * Sin ( Sec ( (A * B) / (||A|| * ||B||) ) )

y se que todo esto es equitativo y debe de dar el mismo resultado como es logico.

Dulces Lunas!¡.
22  Programación / Programación Visual Basic / [SRC] cListLink (Lista enlazada... mejor dicho bloques enlazados.) en: 20 Septiembre 2011, 08:24 am
Estoy un poco aburrido y me e puesto a hacer esto:

Esta clase la he creado para tratar un poco las listas enlazadas de la manera:

Elemento 1, Elemento 2, ... , Elemento N

Es decir que la clase EMULA las listas enlazadas que libremente se pueden escribir con punteros en C/C++ pero en listas lineales.

* No estan enlazadas en forma de arbol.

De tal modo que Dejo de sustitucion a  Redim Preserve   NO en todos los casos Ojo.

Ventajas:

* Asigna memoria dependiendo sin cambiar la hubicacion de los demas elementos ( agregacion rapida de elementos ).
* Se trata a la memoria como un bloque de bytes como cualquier otro (Generico).


Desventajas:

* No se puede usar Copymemory para copiar a mas de 1 elemento...
* Solo es utilizable para casos contados...


cListLink.cls

Código
  1.  
  2. '
  3. '   /////////////////////////////////////////////////////////////
  4. '   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
  5. '   //                                                         //
  6. '   // Web:     http://InfrAngeluX.Sytes.Net/                  //
  7. '   //                                                         //
  8. '   //    |-> Pueden Distribuir Este codigo siempre y cuando   //
  9. '   // no se eliminen los creditos originales de este codigo   //
  10. '   // No importando que sea modificado/editado o engrandecido //
  11. '   // o achicado, si es en base a este codigo                 //
  12. '   /////////////////////////////////////////////////////////////
  13. '   //                                                         //
  14. '   // * Esta es una lista de 1 solo Orden... es decir no es   //
  15. '   // de ordenamiento en arbol...                             //
  16. '   //                                                         //
  17. '   /////////////////////////////////////////////////////////////
  18. '   // http://infrangelux.hostei.com/index.php?option=com_content&view=article&id=29:clistlink&catid=15:catmoduloscls&Itemid=24
  19. '   /////////////////////////////////////////////////////////////
  20.  
  21. Option Explicit
  22.  
  23. Private Const MEM_DECOMMIT = &H4000
  24. Private Const MEM_RELEASE = &H8000
  25. Private Const MEM_COMMIT = &H1000
  26. Private Const MEM_RESERVE = &H2000
  27. Private Const MEM_RESET = &H80000
  28. Private Const MEM_TOP_DOWN = &H100000
  29. Private Const PAGE_READONLY = &H2
  30. Private Const PAGE_READWRITE = &H4
  31. Private Const PAGE_EXECUTE = &H10
  32. Private Const PAGE_EXECUTE_READ = &H20
  33. Private Const PAGE_EXECUTE_READWRITE = &H40
  34. Private Const PAGE_GUARD = &H100
  35. Private Const PAGE_NOACCESS = &H1
  36. Private Const PAGE_NOCACHE = &H200
  37. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pDest As Long, ByVal pSrc As Long, ByVal ByteLen As Long)
  38. Private Declare Function VirtualAlloc Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
  39. Private Declare Function VirtualFree Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
  40. Private Declare Function VirtualLock Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long) As Long
  41. Private Declare Function VirtualUnlock Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long) As Long
  42. 'Private Declare Function IsBadReadPtr Lib "kernel32" (ByVal lp As Long, ByVal ucb As Long) As Long
  43. 'Private Declare Function IsBadWritePtr Lib "kernel32" (ByVal lp As Long, ByVal ucb As Long) As Long
  44. 'Private Declare Function IsBadStringPtr Lib "kernel32" Alias "IsBadStringPtrA" (ByVal lpsz As Long, ByVal ucchMax As Long) As Long
  45. 'Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpStringDest As String, ByVal lpStringSrc As Long) As Long
  46. 'Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Long) As Long
  47. Private Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (ByVal Destination As Long, ByVal Length As Long)
  48.  
  49. Private Declare Sub PutMem4 Lib "msvbvm60" (ByVal Addr As Long, ByVal NewVal As Long)
  50. Private Declare Sub GetMem4 Lib "msvbvm60" (ByVal Addr As Long, ByVal RetVal As Long)
  51.  
  52. Dim pfirst          As Long
  53. Dim pLast           As Long
  54. Dim lSize           As Long
  55.  
  56. Const SIZEAB        As Long = &H8
  57. Const BEFORESIZE    As Long = &H0
  58. Const AFTERSIZE     As Long = (BEFORESIZE + &H4)
  59.  
  60. Public Function release(ByVal pStream As Long) As Boolean
  61. Dim lSizeF      As Long
  62. Dim pAfter       As Long
  63. Dim pBefore     As Long
  64.    If (pStream = &H0) Then Exit Function
  65.    lSizeF = (SIZEAB + lSize)
  66.    pAfter = after(pStream)
  67.    pBefore = before(pStream)
  68.    VirtualUnlock pStream, lSizeF
  69.    VirtualFree pStream, lSizeF, MEM_DECOMMIT
  70.    VirtualFree pStream, 0, MEM_RELEASE
  71.    If (pAfter) Then putBefore pAfter, pBefore
  72.    If (pBefore) Then putAfter pBefore, pAfter
  73.    If (pStream = pfirst) Then pfirst = pBefore
  74.    If (pStream = pLast) Then pLast = pAfter
  75.    release = True
  76. End Function
  77.  
  78. Public Function getPtr(ByVal lIndex As Long) As Long
  79. '   //  Retorna el puntero del elemento indicado en lIndex.
  80. Dim pTmp            As Long
  81. Dim i               As Long
  82.    pTmp = first()
  83.    Do Until (pTmp = &H0)
  84.        i = (i + &H1)
  85.        If (i > lIndex) Then Exit Do
  86.        pTmp = after(pTmp)
  87.    Loop
  88.    getPtr = pTmp
  89. End Function
  90.  
  91. Public Property Get size() As Long
  92.    size = lSize
  93. End Property
  94.  
  95. Public Property Let size(ByVal lVal As Long)
  96.    Call clear
  97.    lSize = lVal
  98. End Property
  99.  
  100. Friend Sub writeStream(ByVal pStruct As Long, ByVal pData As Long)
  101. '   //  Setea los valores en el bloque de la memoria de la lista enlazada.
  102.    CopyMemory pStruct, pData, lSize
  103. End Sub
  104.  
  105. Friend Function readStream(ByVal pStruct As Long, ByVal pData As Long)
  106. '   //  Retorna los valores del bloque de la lista enlazada a una bloque.
  107.    CopyMemory pData, pStruct, lSize
  108. End Function
  109.  
  110.  
  111. '   //  Estas funciones otienen el 1er y ultimo elemento agregado a la lista.
  112. Friend Function first() As Long
  113.    first = pfirst
  114. End Function
  115.  
  116. Friend Function last() As Long
  117.    last = pLast
  118. End Function
  119.  
  120.  
  121. '   //  funciones iteradoras.
  122. Friend Function after(ByVal pStruct As Long) As Long    '   //  Rectorna del puntero al bloque que se agrego despues de pStruct
  123. Dim pTmp            As Long
  124.    If (pStruct = &H0) Then Exit Function
  125.    GetMem4 ByVal (pStruct + lSize + AFTERSIZE), VarPtr(pTmp)
  126.    after = pTmp
  127. End Function
  128.  
  129. Friend Function before(ByVal pStruct As Long) As Long   '   //  Rectorna del puntero al bloque anteriormente agregado de pStruct
  130. Dim pTmp            As Long
  131.    If (pStruct = &H0) Then Exit Function
  132.    GetMem4 ByVal (pStruct + lSize + BEFORESIZE), VarPtr(pTmp)
  133.    before = pTmp
  134. End Function
  135.  
  136. Friend Function addNew() As Long                        '   //  Agrega un nuevo bloque y lo enlaza.
  137. Dim lSizeF      As Long
  138. Dim pNew        As Long
  139.    lSizeF = (SIZEAB + lSize)
  140.    pNew = VirtualAlloc(ByVal 0&, lSizeF, MEM_COMMIT, PAGE_EXECUTE_READWRITE)
  141.    VirtualLock pNew, lSizeF
  142.    ZeroMemory pNew, lSizeF                             '   //  llenamos de 0 el bloque.
  143.    If (pLast) Then                                     '   //  Actualizamos el ultimo...
  144.        putBefore pNew, pLast
  145.        putAfter pLast, pNew
  146.    End If
  147.    If (pfirst = &H0) Then pfirst = pNew
  148.    pLast = pNew
  149.    addNew = pNew
  150. End Function
  151.  
  152. Private Sub putAfter(ByVal pStruct As Long, ByVal pAfter As Long)
  153.    If (pStruct = &H0) Then Exit Sub
  154.    PutMem4 (pStruct + lSize + AFTERSIZE), pAfter        '   //  pNew.After
  155. End Sub
  156.  
  157. Private Sub putBefore(ByVal pStruct As Long, ByVal pBefore As Long)
  158.    If (pStruct = &H0) Then Exit Sub
  159.    PutMem4 (pStruct + lSize + BEFORESIZE), pBefore     '   //  pNOW.BEFORE
  160. End Sub
  161.  
  162. Public Function clear() As Long                         '   //  Libera la memoria asignada y retorna la cantidad liberada en bytes.
  163. Dim lSizeRet        As Long
  164. Dim pTmp            As Long
  165.    pTmp = first()      '   //  Seteamos el 1ro.
  166.    Do Until (release(pTmp) = False)
  167.        lSizeRet = (lSizeRet + lSize + SIZEAB)
  168.        pTmp = first()
  169.    Loop
  170.    clear = lSizeRet
  171. End Function
  172.  
  173. Private Sub Class_Terminate()
  174.    Call clear
  175. End Sub
  176.  
  177.  

Ejemplo de uso

Código
  1.  
  2. Option Explicit
  3.  
  4. Private Type DATOSPERSONALES
  5.    edad        As Long
  6.    categoria   As Long
  7.    nombre      As String * 20
  8.    apellidoP   As String * 10
  9.    apellidoM   As String * 10
  10. End Type
  11.  
  12. Private Sub Form_Load()
  13. Dim oList       As cListLink
  14. Dim tDatosP     As DATOSPERSONALES      '   //  Plantilla...
  15. Dim pElement    As Long                 '   //  Puntero al elemento...
  16.  
  17.    Set oList = New cListLink
  18.  
  19.    oList.size = LenB(tDatosP)                                  '   //  Tamaño de la estructura (bloque de datos).
  20.  
  21.    With tDatosP
  22.        .edad = 22
  23.        .categoria = 1
  24.        .nombre = "Miguel Angel"
  25.        .apellidoP = "Ortega"
  26.        .apellidoM = "Avila"
  27.    End With
  28.    Call oList.writeStream(oList.addNew(), VarPtr(tDatosP))     '   //  Escribimos la estructura en una lista enlazada.
  29.  
  30.    With tDatosP
  31.        .edad = 42
  32.        .categoria = 2
  33.        .nombre = "Angel"
  34.        .apellidoP = "Ortega"
  35.        .apellidoM = "Hernandez"
  36.    End With
  37.    Call oList.writeStream(oList.addNew(), VarPtr(tDatosP))     '   //  Escribimos la estructura en una lista enlazada.
  38.  
  39.    With tDatosP
  40.        .edad = 19
  41.        .categoria = 2
  42.        .nombre = "Maria Luisa"
  43.        .apellidoP = "Beltran"
  44.        .apellidoM = "Ramirez"
  45.    End With
  46.    Call oList.writeStream(oList.addNew(), VarPtr(tDatosP))     '   //  Escribimos la estructura en una lista enlazada.
  47.  
  48.  
  49.    'Call oList.release(oList.before(oList.firts()))             '   //  Liberamos el 2 registro ("Angel Ortega Hernandez"), para eso obtenemos el 1 elemento y obtenemos el siguiente elemento con before...
  50.    Call oList.release(oList.getPtr(1))                         '   //  Eliminamos el elemento con Index 1
  51.  
  52.    '   //  Retornamos los elementos...
  53.  
  54.    pElement = oList.first()
  55.  
  56.    Do Until (pElement = &H0)
  57.  
  58.        oList.readStream pElement, VarPtr(tDatosP)
  59.        With tDatosP
  60.            Debug.Print "Nombre:", .nombre
  61.            Debug.Print "ApellidoP:", .apellidoP
  62.            Debug.Print "ApellidoM:", .apellidoM
  63.            Debug.Print "Edad:", .edad
  64.            Debug.Print "Categoria:", .categoria
  65.            Debug.Print
  66.            Debug.Print
  67.            Debug.Print
  68.        End With
  69.        pElement = oList.after(pElement)
  70.    Loop
  71.  
  72.    Set oList = Nothing
  73.  
  74. End Sub
  75.  
  76.  

Temibles Lunas!¡.
23  Programación / Programación Visual Basic / Propocision de Retos... Matando el tiempo. en: 18 Septiembre 2011, 03:21 am
.
El tema es proponer retos discutir su dificultad y por ende sacar a flote dicho tema respectivamente en un hilo ajeno a este, ya que proponer un reto la vdd no es cosa facil, por ejemplo:

Proponer crear una aplicacion X discutiendo su complejidad.
Proponer la recreacion de la funcion X.
Proponer la creacion de alguna indole X.

Que debera llevar ...?
Que se espera de ...?
Prototipo de la funcion ...?

Por ejemplo: tengo en mente proponer un 3 retos los cuales son:

Crear un interprete...
Crear un lector de estructuras en arbol (como XML, HTTP, etc)...
Otro que no por el momento.

Puedo decir que el interprete tiene una dificultad Intermedio-Avanzado y el lector de estructuras en arbol seria un nivel Intermedio, pero por el momento SUPONGAMOS que en el interprete digo que haga X cosas... pero me lleguen a faltar mas cosillas; es decir discutir SOLAMENTE lo que debe esperarse de este mas que codigo deberia llevar Por ejemplo:

* Manejo de procesos y funciones.
* Manejo de variables con sus tipos X (Dim nombre as tipo).
* Con que tipos de variables debe contar.
* Funciones predeterminadas del interprete (Mid, Left, IndexOf, ...).
* Instrucciones de flujo (If then, select case o Switch, ...).
* Bucles (dow while, for(), ...).
* forma de retornar los valores (por la instruccion return o como lo hace vb6).
* Entre otras cosillas.
* Ademas de incluir ejemplos.

Este ultimo me es interesante puesto que se podrian crear entre 2 o mas personas claro que tambien 1 podria hacerlo, ademas de que fomentaria el compañerismo del foro.

Esta es una propocision.

Cada Post para no hacerlo lago deberia llevar una cita de link mas no citar completamente el tema esto ultimo para mantener un orden en el tema hilo.

Dulces Lunas!¡.
24  Programación / Programación C/C++ / [C]isNumeric (VB6 a C) en: 16 Agosto 2011, 22:45 pm
.
Se trabajan las funciones a nivel Bit, ambas funciones son mas rapidas que la nativa en vb6.

Funcion en VB6

Codigos para descargar...
Archivos Fuente dll, y Compilados



La funcion isnumeric_Black esta en VB6, es la version en vb6 de la que esta aqui...

Código:

http://foro.elhacker.net/programacion_visual_basic/reto_reemplazo_de_funcion_isnumeric-t336067.0.html;msg1652210#msg1652210

main.cpp


y aqui les dejo la traduccion en C (Las funciones IsNumericA y IsNumericW estan configuradas para trabajar con las Strings de VB6)

Código
  1.  
  2. #include "main.h"
  3.  
  4. /**
  5.     @Autor          BlackZeroX
  6.     @Web            http://infrangelux.sytes.net/blog/
  7.     @Reference      http://foro.elhacker.net/programacion_visual_basic/reto_reemplazo_de_funcion_isnumeric-t336067.0.html;msg1652210#msg1652210
  8.     @Description    Libreria para verificar si una Cadena de texto ANSI/UNICODE es numerica con los siguientes formatos:
  9.                     * ###e[+/-]###  {+/-646.45e+546,45}.
  10.                     * ###d[+/-]###  {+/-646.45d+546,45}.
  11.                     * Base 16       {&H4561abcdef}.
  12.                     * Base 10       {+/-456,541.456,545}.
  13.     @Returns        0 si la cadena no contiene ningun formato.
  14.                     1 si la cadena pertenece a algun tipo de formato numerico.
  15. **/
  16.  
  17. #define PUNTO_DECIMAL     0x10000
  18. #define SIGNO_SRC         0x20000
  19. #define NUMBER_HEX        0x40000
  20. #define NUMBER_HEX_ZERO   0x80000
  21. #define NUMBER_HEX_FLAGS  (NUMBER_HEX | NUMBER_HEX_ZERO)
  22. #define NUMBER_POW        0x100000
  23. #define NUMBER_POW_FINISH 0x200000
  24. #define NUMBER_POW_FLAGS  (NUMBER_POW | NUMBER_POW_FINISH)
  25. #define NUMBER_OF_OK      0x400000
  26. #define NUMBER_OF_FINISH  0x800000
  27. #define NUMBER_OF_FLAGS   (NUMBER_OF_OK | NUMBER_OF_FINISH)
  28.  
  29. DLL_EXPORT int __stdcall IsNumericA (char *pStr) { return pStr ? IsNumericEx(pStr, *((int*)(pStr - 0x4)), 1): 0; }
  30. DLL_EXPORT int __stdcall IsNumericW (char *pStr) { return pStr ? IsNumericEx(pStr, *((int*)(pStr - 0x4)), 2): 0; }
  31.  
  32. int IsNumericEx (char *pStr, size_t uiLn, int iStep) {
  33. unsigned int i       = 0x0,  //  For()
  34.             iData   = 0x0;  //  Xor, Switcher, Contador (QWord).
  35.  
  36.    if (!pStr || !uiLn)
  37.        return 0;
  38.  
  39.    for (i = 0; i < uiLn; i += iStep) {
  40.        if ((iData & NUMBER_HEX) == NUMBER_HEX) {
  41.            if (((*pStr >= 0x30) && (*pStr <= 0x39)) ||
  42.               ((*pStr >= 0x61) && (*pStr <= 0x66)) ||
  43.               ((*pStr >= 0x41) && (*pStr <= 0x46))) {  //  Numeros Hexadecimales
  44.                if ((iData & NUMBER_OF_FLAGS) == 0x0)   //  Ceros a la izquierda
  45.                    iData |= (*pStr == 0x30) ? NUMBER_HEX_ZERO : NUMBER_OF_OK;
  46.  
  47.                switch (iData & NUMBER_OF_FLAGS) {
  48.                    case NUMBER_OF_OK:
  49.                        iData++;
  50.                        if ((iData & 0xFF) == 0x11)
  51.                            return 0;   //  QWord (Max Double)
  52.                        iData |= NUMBER_OF_OK;
  53.                        if ((iData | NUMBER_HEX_FLAGS) == NUMBER_HEX_FLAGS)
  54.                            iData ^= NUMBER_HEX_ZERO;
  55.                        break;
  56.  
  57.                    case NUMBER_OF_FINISH:
  58.                    case NUMBER_OF_FLAGS:
  59.                        return 0;
  60.                        break;
  61.               }
  62.            } else {
  63.                switch (*pStr) {
  64.                    case 0x9:
  65.                    case 0xA:
  66.                    case 0xB:
  67.                    case 0xC:
  68.                    case 0xD:
  69.                    case 0x24:
  70.                    case 0x20:
  71.                    case 0xA0:  //   Espacios en Blanco
  72.                        if ((iData | NUMBER_HEX_FLAGS) == NUMBER_HEX_FLAGS)
  73.                            iData = ((iData ^ NUMBER_HEX_ZERO) | NUMBER_OF_OK);
  74.                        if ((iData & NUMBER_OF_FLAGS) == NUMBER_OF_OK)
  75.                            iData |= NUMBER_OF_FINISH;
  76.                        break;
  77.  
  78.                    case 0x0:    //  NULL Indica que se termina la cadena.
  79.                        if ((iData & NUMBER_OF_FLAGS) == NUMBER_OF_FINISH)
  80.                            return 0;
  81.                        i = uiLn; //  Exit For.
  82.                        break;
  83.  
  84.                    default:
  85.                        return 0;
  86.                        break;
  87.                }
  88.            }
  89.        } else {
  90.            if ((*pStr >= 0x30) && (*pStr <= 0x39)) {
  91.                iData |= NUMBER_OF_OK;
  92.                if ((iData & NUMBER_OF_FINISH) == NUMBER_OF_FINISH)
  93.                    return 0;
  94.                if ((iData & NUMBER_POW_FLAGS) == NUMBER_POW)
  95.                    iData |= NUMBER_POW_FINISH;
  96.  
  97.            } else {
  98.                switch ((int)*pStr) {
  99.                    case 0x0:    //  NULL Indica que se termina la cadena.
  100.                        if ((iData & NUMBER_POW_FLAGS) == NUMBER_POW)
  101.                            return 0;
  102.                        i = uiLn;    //  Exit For.
  103.                        break;
  104.  
  105.                    case 0x2E:   //  "."  Solo 1
  106.                        if (((iData & NUMBER_POW_FLAGS) == NUMBER_POW) ||
  107.                           ((iData & NUMBER_OF_FINISH) == NUMBER_OF_FINISH) ||
  108.                           ((iData & PUNTO_DECIMAL) == PUNTO_DECIMAL))
  109.                            return 0;
  110.                        iData |= PUNTO_DECIMAL;
  111.                        break;
  112.  
  113.                    case 0x2B:
  114.                    case 0x2D: //  "+|-" Solo 1
  115.                        if ((iData & NUMBER_POW_FLAGS) == NUMBER_POW)
  116.                            iData |= NUMBER_POW_FINISH;
  117.  
  118.                        else
  119.                            if (((iData & NUMBER_OF_OK) == NUMBER_OF_OK) ||
  120.                               ((iData & PUNTO_DECIMAL) == PUNTO_DECIMAL) ||
  121.                               ((iData & SIGNO_SRC) == SIGNO_SRC))
  122.                            return 0;
  123.  
  124.                        if ((iData & NUMBER_OF_FINISH) == NUMBER_OF_FINISH)
  125.                            return 0;
  126.  
  127.                        iData |= SIGNO_SRC;
  128.                        break;
  129.  
  130.                    case 0x2C:
  131.                        if ( !((iData & NUMBER_OF_OK) == NUMBER_OF_OK) ||
  132.                              ((iData & NUMBER_POW_FLAGS) == NUMBER_POW))
  133.                            return 0;
  134.                        break;
  135.  
  136.                    case 0x9:
  137.                    case 0xA:
  138.                    case 0xB:
  139.                    case 0xC:
  140.                    case 0xD:
  141.                    case 0x24:  //  Solo se permiten al inicio de un Numero (Espacios en Blanco).
  142.                        if (((iData & PUNTO_DECIMAL) == PUNTO_DECIMAL) ||
  143.                           ((iData & NUMBER_OF_FINISH) == NUMBER_OF_FINISH) ||
  144.                           ((iData & NUMBER_OF_OK) == NUMBER_OF_OK) ||
  145.                           ((iData & NUMBER_POW_FLAGS) == NUMBER_POW))
  146.                            return 0;
  147.                        break;
  148.  
  149.                    case 0xA0:
  150.                    case 0x20: //  Se permiten al Inicio/final de un numero.
  151.                        if ((iData & NUMBER_OF_OK) == NUMBER_OF_OK)
  152.                            iData |= NUMBER_OF_FINISH;
  153.                        else
  154.                            if (((iData & PUNTO_DECIMAL) == PUNTO_DECIMAL) ||
  155.                               ((iData & NUMBER_POW_FLAGS) == NUMBER_POW))
  156.                                return 0;
  157.                        break;
  158.  
  159.                    case 0x26:   //  Es un Numero Hexadecimal
  160.                        if (((iData & NUMBER_OF_FINISH) == NUMBER_OF_FINISH) ||
  161.                           ((iData & NUMBER_OF_OK) == NUMBER_OF_OK) ||
  162.                           ((iData & SIGNO_SRC) == SIGNO_SRC) ||
  163.                           ((iData & PUNTO_DECIMAL) == PUNTO_DECIMAL) ||
  164.                           ((iData & NUMBER_POW_FLAGS) == NUMBER_POW))
  165.                            return 0;
  166.  
  167.                        pStr += iStep;
  168.  
  169.                        if ((*pStr == 0x48) || (*pStr == 0x68)) {
  170.                            iData |= NUMBER_HEX;
  171.                            iData ^= 0xFF000000;
  172.                            i += iStep;
  173.                        } else {
  174.                            pStr -= iStep;
  175.                        }
  176.                        break;
  177.  
  178.                    case 0x44:
  179.                    case 0x45:
  180.                    case 0x64:
  181.                    case 0x65:     //  Numeros en Formato ###e-###, ###e+###
  182.                        if (((iData & NUMBER_OF_FINISH) == NUMBER_OF_FINISH) ||
  183.                           ((iData & NUMBER_POW) == NUMBER_POW))
  184.                            return 0;
  185.                        if ((iData & NUMBER_OF_OK) == NUMBER_OF_OK) {
  186.                            iData |= NUMBER_POW;
  187.                            if ((iData & SIGNO_SRC) == SIGNO_SRC)
  188.                                iData ^= SIGNO_SRC; //  Permitimos nuevamente los signos "+" y "-".
  189.                        } else {
  190.                            return 0;
  191.                        }
  192.                        break;
  193.  
  194.                    default:
  195.                        return 0;
  196.                        break;
  197.  
  198.                }   //  switch()
  199.            }   //  if()
  200.        }   //  if()
  201.        pStr += iStep;
  202.    }   //  For()
  203.  
  204.    switch (iData & NUMBER_OF_FLAGS) {
  205.        case NUMBER_OF_OK:
  206.        case NUMBER_OF_FLAGS:
  207.            return 1;
  208.            break;
  209.  
  210.        default:
  211.            switch (iData & NUMBER_HEX_FLAGS) {
  212.                case NUMBER_HEX_FLAGS:
  213.                    return 1;
  214.                    break;
  215.            }
  216.    }
  217.  
  218.    return 0;
  219. }
  220.  
  221.  

main.h
Código
  1.  
  2. #ifndef __MAIN_H__
  3. #define __MAIN_H__
  4.  
  5. #include <windows.h>
  6.  
  7. #ifdef BUILD_DLL
  8.    #define DLL_EXPORT __declspec(dllexport)
  9. #else
  10.    #define DLL_EXPORT __declspec(dllimport)
  11. #endif
  12.  
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif
  17.  
  18. DLL_EXPORT int __stdcall IsNumericA (char*);
  19. DLL_EXPORT int __stdcall IsNumericW (char*);
  20. int IsNumericEx (char *pStr, size_t uiLn, int iStep);
  21.  
  22. #ifdef __cplusplus
  23. }
  24. #endif
  25.  
  26. #endif // __MAIN_H__
  27.  
  28.  

Dulces Lunas!¡.
25  Programación / Programación C/C++ / Crear DLL en: 16 Agosto 2011, 04:42 am
Como creo una DLL en codeblocks pero que pueda usar sus funciones en otro lenguaje por ejemplo VB6, vb .NET etc...

Dulces Lunas!¡.
26  Programación / Programación C/C++ / OpenGL ( Error Luz ). No apunta a donde deberia. en: 23 Julio 2011, 09:52 am
.
Estoy realizando pruebas con OpenGL+C ( No me recomienden otro por que antes de cambiarme quiero solucionar este problema ), y estoy con las luces. mi problema radica en que la luz no apunta a donde deberia de apunter ( Algo asi como un Eje ), ya que se mueve emisor d ela luz a otra coordenada y obviamente el eje (en este caso esta representado con una espera solida) deberia estar SIEMPRE iluminado, pero no es asi...

alguien me puede ayudar?

Código
  1.  
  2. #include <windows.h>
  3. #include "include/OpenGL/CGL.h"
  4.  
  5. // Posicion de la luz X, Y, Y, {el 4to elemento indica si es en una posicion infinita 1=NO, 0=SI}
  6. float fposition[4] = {0.0f, 0.0f, 1.0f, 1.0};
  7.  
  8. void drawZones()
  9. {
  10.    ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // Borramos la pantalla y el buffer de profundidad
  11.  
  12.    ::glLoadIdentity();
  13.    //  Camara.
  14.    ::gluLookAt( 0, 0, 5,               //  Posicon X, Y, Z.
  15.                 0, 0, -1,              //  Hacia donde vemos X, Y, Z.
  16.                 0.0f, 1.0f, 0.0f );    // Cielo X, Y, Z.
  17.  
  18.    GLfloat fDirection[] = {0.0,0.0,-1.0}; // Dirrecion hacia adonde apuntamos.
  19.    //Configuramos nuestra Luz.
  20.    ::glEnable ( GL_LIGHT0 );
  21.    ::glLightfv ( GL_LIGHT0, GL_POSITION, fposition );
  22.    ::glLightfv ( GL_LIGHT0, GL_SPOT_DIRECTION, fDirection);
  23.    ::glLightf ( GL_LIGHT0, GL_SPOT_CUTOFF, 5 );
  24.  
  25.    ::glutSolidSphere(100, 4000, 4000); // Esfero que nos representara las paredes.
  26.  
  27.    //  Las siguiente son las esferas donde esta la luz.
  28.    //  Posicion del emisor de luz.
  29.    ::glPushMatrix ();
  30.        ::glColor3f ( 1.0f , 0.0f , 0.0f );
  31.        ::glTranslatef ( fposition[0],fposition[1],fposition[2] );
  32.        ::glutWireSphere ( 0.2, 50 , 50 );
  33.    ::glPopMatrix ();
  34.  
  35.    //  Posicion Destino hacia donde se emite la luz.
  36.    ::glPushMatrix();
  37.        ::glColor3f( 0.0f , 0.0f , 1.0f );
  38.        ::glTranslatef( fDirection[0],fDirection[1],fDirection[2] );
  39.        ::glutSolidSphere( 0.2, 50 , 50 );
  40.    ::glPopMatrix();
  41.    //  Mostramos.
  42.    ::glutSwapBuffers();
  43. }
  44.  
  45. void keyBoardSFunc(int key, int x, int y)
  46. {
  47.    if (key == GLUT_KEY_LEFT)
  48.        fposition[0] -= 0.1;
  49.    if (key == GLUT_KEY_RIGHT)
  50.        fposition[0] += 0.1;
  51.    if (key == GLUT_KEY_UP)
  52.        fposition[1] -= 0.1;;
  53.    if (key == GLUT_KEY_DOWN)
  54.        fposition[1] += 0.1;
  55. }
  56. void timer( int val ) {
  57.    ::glutTimerFunc       ( 10 , timer,  0);
  58.    ::glutPostRedisplay   (  );
  59. }
  60.  
  61. int main()
  62. {
  63.    CGL oWindow;
  64.  
  65.    oWindow.creaVentanaGL ( "Hola Mundo desde OpenGL" , 1024 , 726 , 0 , 0 , false );
  66.    ::glutDisplayFunc ( drawZones );
  67.    ::glutSpecialFunc ( keyBoardSFunc );
  68.    ::glutTimerFunc ( 10, timer, 0 );
  69.    ::glutMainLoop ();
  70.  
  71.    return EXIT_SUCCESS;
  72. }
  73.  
  74.  

CGL.cpp

Código
  1.  
  2.  
  3. #include "OpenGL/cgl.h"
  4.  
  5. //---------------------------------------------------------------
  6. // Nombre: Constructor
  7. // Descripcion: Constructor de la clase. Inicializa las variables
  8. // Parametros: Ninguno
  9. //---------------------------------------------------------------
  10. CGL::CGL()
  11. {
  12.    int_Win = 0;
  13. }
  14.  
  15. //---------------------------------------------------------------
  16. // Nombre: Destructor
  17. // Descripcion: Destructor de la clase
  18. // Parametros: Ninguno
  19. //---------------------------------------------------------------
  20. CGL::~CGL()
  21. {
  22.    eliminaVentanaGL();
  23. }
  24.  
  25. //---------------------------------------------------------------
  26. // Nombre: inicializaEscenaGL
  27. // Descripcion: Inicializa los parametros iniciales de la escena
  28. // Parametros:
  29. //        Glsizei ancho: Ancho de la escena
  30. //        Glsizei alto: Alto de la escena
  31. //---------------------------------------------------------------
  32. void CGL::inicializaEscenaGL(GLsizei ancho, GLsizei alto)
  33. {
  34.    if ( alto <= 0 )                                                                    // Previene de la división entre 0
  35.    {
  36.        alto=1;                                                                         // Establece la altura = 1
  37.    }
  38.    ::glViewport            ( 0 , 0 , ancho , alto );                                   // Resetea el actual puerto de visión (ViewPort)
  39.    ::glMatrixMode          ( GL_PROJECTION );                                          // Selecciona la matriz de proyección
  40.    ::glLoadIdentity        (  );                                                       // Resetea la matriz de proyección
  41.  
  42.    ::gluPerspective        ( 45.0f , (GLfloat)ancho/(GLfloat)alto , 1.0f , 300000.0f );  // Calcula el Aspect Ratio de la ventana
  43.  
  44.    ::glMatrixMode          ( GL_MODELVIEW );                                           // Selecciona la matriz de modelado
  45.    ::glLoadIdentity        (  );                                                       // Resetea la matriz de modelado
  46. }
  47.  
  48. //---------------------------------------------------------------
  49. // Nombre: iniGL
  50. // Descripcion: Inicializa los valores iniciales de OGL
  51. // Parametros: Ninguno
  52. //---------------------------------------------------------------
  53. bool CGL::iniGL(void)
  54. {
  55.    GLfloat ambientLight[]  = { 0.1f, 0.1f, 0.1f, 1.0f };
  56.    ::glShadeModel          ( GL_SMOOTH );                                  // Activa sombreado suave (Smooth Shading)
  57.    ::glClearDepth          ( 1.0f );                                       // Depth Buffer Setup
  58.    ::glEnable              ( GL_DEPTH_TEST );                              // Activa Z-Buffer
  59.    ::glDepthFunc           ( GL_LEQUAL );                                  // El tipo de Depth Testing que se va a realizar
  60.    ::glHint                ( GL_PERSPECTIVE_CORRECTION_HINT , GL_NICEST ); // Muy buena correción de perspectiva
  61.    ::glEnable              ( GL_TEXTURE_2D );                              // Activa mapeado de texturas
  62.    ::glColorMaterial       ( GL_FRONT , GL_AMBIENT_AND_DIFFUSE );
  63.    ::glClearColor          ( 0.0f , 0.0f , 0.0f , 1.0f );
  64.  
  65.    ::glLightModeli         ( GL_LIGHT_MODEL_TWO_SIDE , 1 );                // habilita ambas caras (FRONT-iluminada & BACK-oscurecida) de los poligonos
  66.    ::glLightModelfv        ( GL_LIGHT_MODEL_AMBIENT , ambientLight );      // luz ambiental de toda la escena
  67.    ::glEnable              ( GL_COLOR_MATERIAL);                           // habilita el color para los materiales (poligonos rellenos)
  68.    ::glEnable              ( GL_LIGHTING );
  69.  
  70.    return true;
  71. }
  72.  
  73. //---------------------------------------------------------------
  74. // Nombre: eliminaVentanaGL
  75. // Descripcion: Destruye toda la información sobre la ventana GL
  76. // Parametros: Ninguno
  77. //---------------------------------------------------------------
  78. void CGL::eliminaVentanaGL(void)
  79. {
  80.    ::glutDestroyWindow(  this->int_Win );
  81.    this->int_Win = 0;
  82. }
  83.  
  84. //---------------------------------------------------------------
  85. // Nombre: CrearVentanaGL
  86. // Descripcion: Crea una ventana OGL
  87. // Parametros:
  88. //            char* Titulo: Titulo de la ventana
  89. //            int ancho: Ancho de la ventana o en modo pantalla completa
  90. //            int alto: Alto de la ventana o en modo pantalla completa
  91. //            bool fullscreen: Usar pantalla completa (TRUE) o ventana (FALSE)
  92. //---------------------------------------------------------------
  93. bool CGL::creaVentanaGL(const char* Titulo, GLsizei ancho, GLsizei alto, GLsizei x, GLsizei y, bool fullscreen)
  94. {
  95.    if ( x < 0 ) { x=0; }
  96.    if ( y < 0 ) { y=0; }
  97.  
  98.    ::glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGBA );
  99.    ::glutInitWindowPosition ( x , y );
  100.    ::glutInitWindowSize ( ancho , alto );
  101.  
  102.    this->int_Win = ::glutCreateWindow( Titulo );
  103.  
  104.    ::glutSetWindow( this->int_Win );
  105.  
  106.    if ( fullscreen == true )
  107.        ::glutFullScreen();
  108.  
  109.    inicializaEscenaGL ( ancho , alto );        // Inicializamos la escena en perspectiva GL
  110.  
  111.    if ( !iniGL() ) {
  112.        eliminaVentanaGL();
  113.        return false;
  114.    }
  115.  
  116.    return true;
  117. }
  118.  
  119.  

CGL.h
Código
  1.  
  2. #ifndef _cGL_H_
  3. #define _cGL_H_
  4.  
  5. // INCLUDES //////////////////////////////////////
  6. #include <windows.h>            // Archivo cabecera para Windows
  7. #include <GL/glut.h>
  8.  
  9. class CGL
  10. {
  11.    public:
  12.        CGL                                         ();
  13.        virtual         ~CGL                        ();
  14.        bool            creaVentanaGL               (const char* Titulo, GLsizei ancho, GLsizei alto, GLsizei x, GLsizei y, bool fullscreen);
  15.        void            inicializaEscenaGL          (GLsizei ancho, GLsizei alto);      // Cambia de tamaño e inicializa la ventana GL
  16.        void            eliminaVentanaGL            (void);                           // Elimina la ventana
  17.        int             int_Win;
  18.        void            inilight                    (GLfloat ligt[]);
  19.    private:
  20.        bool            iniGL                       (void);                        // Todas la inicializaciónes de OpenGl vienen aqui
  21. };
  22.  
  23. #endif
  24.  
  25.  

Temibles Lunas!¡
27  Programación / Desarrollo Web / Una ligera duda... en: 22 Julio 2011, 07:44 am
.
Que significa la linea que resalto?

Código
  1.  
  2. var k=function(){
  3.    var l=$("#dtmain_outer, #hatdoiwas_outer");
  4.    if(l.length>0){
  5.    l.remove();
  6.    C.utils.third_party_addon_detected()
  7. }
  8. setTimeout(k,1000)
  9.  
  10.  

No tengo ni idea que significa $( alguien lo sabe? entiendo absolutamente TODO pero mi problema radica en el problema que ya mencione.

Dulces Lunas!¡.
28  Foros Generales / Foro Libre / [?] Necrosis en: 11 Julio 2011, 07:47 am
alguien sabe si la necrosis duele?; se de que trata la necrosis, pero la verdad es que no soy doctor no lo he esperimentado, y bueno quisas alguien mas informado sepa de esto.

Anexo:
Hemos adoptado una palo mensajera, dicha paloma anteriormente venia a nuestra casa constantemente devido a que fue agredida de alguna manera ( alguna aguila ), llego sin un ojo y bueno solo llego a nuesra casa seguro por que tenemos rondando mas palomas, pichones ( Libres de irse cuando quieran no esta atadas ni nada similar ), gallos, gallinas, etc... bueno estos ultimos para la cena de algun dia ( Broma, jamas nos comemos a ninguno ), perros, gatos, y alguna que otro Conejo de ciudad gracias al mercado y a la iglesia detras de nuestra casa; Dicha paloma se hiba y regresaba cada dia, pero un dia no llego y duro al rededor de 3 semanas apenas Hoy llego pero con una necrosis en su pie ( Es facil saber cuando es necrosis, en especial cuando es avanzada ), dicha paloma actualmente mi hermana y un servidor estamos pensando en conrtarle la pata, o de plano ya sacrificarla, ahorita solo la tenemos en una jaula ( anteriormente los conejos de Ciudad se comieron a 1 Paloma completa y lo digo literalmente es por ello este trato ).

Solo desearia saber eso.

Nota: Mi familia y un servidor tenemos corazon de pollo con los animales, es decir, no tenemos mera intencion de maltrato animal.

Dulces Lunas!¡.
29  Programación / Programación C/C++ / [Ayuda] Error con delete[]... algo extraño... en: 7 Julio 2011, 23:33 pm
.
Intento Re-Crear el Redim Preserve de VB6 todo bien pero Cuando deseo volver a redimencionar Crashea alguien sabe por que?

Código
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. void** RedimPreserve( void** __pp_vector , size_t _szt_now, size_t _szt_new )
  6. {
  7.    void            **__pp_back     = __pp_vector;
  8.    void            **__new_ptr     = NULL;
  9.  
  10.    if (_szt_now==_szt_new )
  11.        return __pp_vector;
  12.  
  13.    if ( _szt_new>0 ) {
  14.        __new_ptr       = new void*[_szt_new];
  15.        if ( _szt_now>0 && __new_ptr!=NULL && __pp_back!=NULL  )
  16.            memcpy          ( __new_ptr , __pp_back , _szt_now*sizeof(void*) );
  17.    } else
  18.        __new_ptr       = NULL;
  19.  
  20.    if ( __pp_back!=NULL )
  21.        delete[]        __pp_back;
  22.  
  23.    return __new_ptr;
  24. }
  25.  
  26.  
  27.  
  28. int main () {
  29.    char **_msg = NULL;
  30.  
  31.    _msg    = (char**)RedimPreserve( (void**)_msg , 00 , 10 );
  32.    _msg    = (char**)RedimPreserve( (void**)_msg , 10 , 11 );
  33.    _msg    = (char**)RedimPreserve( (void**)_msg , 11 , 10 );
  34.    _msg    = (char**)RedimPreserve( (void**)_msg , 10 , 00 );
  35.    _msg    = (char**)RedimPreserve( (void**)_msg , 00 , 13 );
  36.    _msg    = (char**)RedimPreserve( (void**)_msg , 13 , 20 );
  37.    delete[] _msg;
  38.    return 0;
  39. }
  40.  
  41.  

Dulces Lunas!¡
30  Programación / Programación General / Buscas algun codigo...!? en: 19 Junio 2011, 06:51 am
.
Me a parecido fantástico este buscador, asi que se los comparto.

Google Code Search

Temibles Lunas!¡.
Páginas: 1 2 [3] 4 5 6 7 8 9 10 11 12 13 14
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines