Skip to content

Instantly share code, notes, and snippets.

View hpcorona's full-sized avatar

Hilario Pérez Corona hpcorona

  • Google
  • Washington
View GitHub Profile
@hpcorona
hpcorona / UTF8SaveText
Created July 13, 2011 22:04
Save a UTF-8 text file on WinDev
PROCEDURE UTF8SaveText(LOCAL FileName, Content)
fSaveText(FileName, Charact(0xEF) + Charact(0xBB) + Charact(0xBF) + Content)
MyArray is array of int
ArraySort(MyArray, asAscending)
ArrayAddSorted(MyArray, ElementToAdd)
Idx is int = ArraySeek(MyArray, asBinary, ElementToSearch)
@hpcorona
hpcorona / cfdi3_timbre.xslt
Created October 17, 2011 21:21
XSLT para sacar la cadena original del timbre de un CFDi
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:tfd="http://www.sat.gob.mx/TimbreFiscalDigital" version="1.0">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:template name="Requerido"><xsl:param name="valor"/>|<xsl:call-template name="ManejaEspacios"><xsl:with-param name="s" select="$valor"/></xsl:call-template></xsl:template>
<xsl:template name="ManejaEspacios">
<xsl:param name="s"/>
<xsl:value-of select="normalize-space(string($s))"/>
</xsl:template>
<xsl:template match="/"><xsl:apply-templates select="./cfdi:Comprobante"/></xsl:template>
<xsl:template match="cfdi:Comprobante"><xsl:apply-templates select="./cfdi:Complemento"/></xsl:template>
PROCEDURE TemplateBuild(LOCAL sTemplate is string, Variables is assosiative array of strings)
sOpenBrace is string = "${"
sCloseBrace is string = "}"
sNewStr is string = ""
nUPos is int = 1
nPos is int
nPos = Position(sTemplate,sOpenBrace)
Template is string = [
Hi Mr. %1, Your product %2 has ben fixed!
]
Email is string = StringBuild(Template, Customer.Name, Product.Name)
Template is string = [
Hi Mr. ${Customer.Name}, Your product ${Product.Name} has ben fixed!
]
Variables is associative array of strings
Variables["Customer.Name"] = "Hilario Perez"
Variables["Product.Name"] = "HP Laptop"
Email is string = TemplateBuild(Template, Variables)
@hpcorona
hpcorona / gist:1608339
Created January 13, 2012 19:46
Code to Copy a Tree Node from a TableTreeView on WinDev
PROCEDURE CopyTreeNode(LOCAL TableTree, nIdx is int)
sRow is string = ""
// If no item is selected, then return an empty string
IF {TableTree, indItem} < 1 THEN RESULT ""
// Count the columns, we'll need them
CCount is int = TableCount(TableTree,toColumn)
@hpcorona
hpcorona / gist:1608418
Created January 13, 2012 20:02
Code to Paste a Tree Node in a TableTreeView in WinDev
PROCEDURE PasteTreeNode(LOCAL TableTree, LOCAL nIdx is int, LOCAL CopiedNode is string, LOCAL AsChild is boolean = False)
nParentIdx is int = 0
nRelPos is int = 0
nRelIdx is int = nIdx
IF AsChild = False THEN
nParentIdx = TableGiveParent(TableTree, nIdx)
ELSE
nParentIdx = nIdx
nRelIdx = TableCount(TableTree)