7351
Foros Generales / Sugerencias y dudas sobre el Foro / Re: Sugerencia para todos los moderadores de Programación.
en: 3 Abril 2014, 14:35 pm
Bueno, como mis intentos por saber más acerca del tema quedaron en vano... y soy un poco impaciente (lo se, es un defecto) me he tomado la iniciativa propia de hacer realiad esta gran idea:
•
¡¡¡ NUEVA REGLA QUE DEBEN SEGUIR TODOS LOS POSTS, LEER ANTES DE POSTEAR !!!! El siguiente paso será intentar añadir esta regla al subforo de programación .NET, donde ahora mismo estoy a la espera de la opininón de los compañeros que moderan esa sección.
PD: Si esta idea tiene la suficiente aceptación por encima de los que mandan sobre mi (yo solo soy un simple mod y un poco acojonado por si la idea desaagrada a los que si que mandan algo) entonces creo que será algo genial y estoy seguro que en el futuro lo podrán perfeccionar con un mod para SMF que se encargue de automatizar esta tarea.
Un saludo!
7352
Programación / Scripting / Re: Funciona
en: 3 Abril 2014, 14:18 pm
el problema es que me me pega todos los números juntos
En mi caso funcionó corréctamente al añadirle un salto de linea (\n), pero prueba a reemplazar la expresión regular por esta otra:
objRegEx.Pattern = "[^0-9\n" & VBcrlf & "]"
Si eso te sigue sin funcionar entonces pásame el archivo de texto por MP para examinarlo, si quieres.
Saludos!
7353
Programación / Scripting / Re: Modificar un archivo de texto, solo sacar las letras y dejarme solo los números
en: 3 Abril 2014, 12:48 pm
En
Batch sería bastante engorroso, una pérdida de tiempo para la cantidad de escritura que requeriría y lo no demasiado eficiente que sería el resultado final, necesitarías procesar y comparar cada caracter de cada linea haciendole
Substring con un
Loop , sinceramente habiendo otras muchas mejores y decentes alternativas no estoy por la labor de codear un ejemplo en Batch, pero es algo facil de encontrar en Google.
Si tu objetivo es usar cualquier lenguaje que esté soportado nativamente en Windows entonces puedes usar
VisualBasicScript junto a una expresión regular:
NumericChars = RemoveNonNumerics(".\Archivo.txt" )
Set NewFile = CreateObject ("Scripting.FileSystemObject" ). _
CreateTextFile(".\Archivo.txt" , True )
NewFile.Write NumericChars
NewFile.Close
Wscript.Quit(0)
' By Elektro
Function RemoveNonNumerics(TextFile)
TextContent = CreateObject ("Scripting.FileSystemObject" ). _
OpenTextFile(TextFile, 1, False ).ReadAll
Set objRegEx = CreateObject ("VBScript.RegExp" )
objRegEx.Global = True
objRegEx.Pattern = "[^0-9\n]"
RemoveNonNumerics = objRegEx.Replace(TextContent, "" )
End Function
Saludos.
7356
Foros Generales / Dudas Generales / Opiniones sobre servicios Multihoster (Multiples Premum en Uploaded,RG,MG, etc)
en: 3 Abril 2014, 10:44 am
Hola
Habitualmente yo compro una subscripción Premium de 3 meses a
Uploaded.net (25€), y ...bueno, la subscripción se me ha acabado y en lugar de renovarla otra vez estoy pensando seriamente en comprar otra alternativa que siempre me pareció mejor pero nunca me atreví a comprar, me refiero a servicios que ofrecen muchas cuentas Premium (de forma legal) para distintos servidores y por mucho menos dinero.
Por ejemplo:
http://multihosters.com/selectProduct.aspx o...:
http://zevera.com/Prices.aspx#prices Y aquí hay más:
http://www.kulhead.com/2013/09/5-most-powerful-multihosters.html · ¿Alguien ha experimentado este tipo de servicios? ...¿Son de fiar?, ¿Algo que pinar? · ¿Reálmente todas las cuentas Premium que dicen tener activas ...lo están siempre? · ¿Recomiendan algun servicio parecido en especial? A mi lo que me da miedo es que por ejemplo sea más un timo que otra cosa, y que de repente una cuenta deje de funcionar y no puedas reclamar nada y pierdas a mala leche el dinero que has pagado por no poder descargar como Premium de ese hosting, o cosas parecidas.
Saludos
7357
Programación / Scripting / Re: [IMPRESIONANTE] Crear Formularios en VBS!
en: 3 Abril 2014, 10:09 am
¿Pero para ejecutarlos es necesario tener instaladas las dll?
Si
Imagino que, como alternativa, se podría portabilizar, empaquetando las librerías y el archivo .VBS todo en un único exe (por ejemplo con la herramienta
ExeScript ).
Saludos!
7358
Programación / Scripting / Re: AYUDA! CODIFICAR VBSCRIPT
en: 3 Abril 2014, 10:01 am
Creo que la otra vez que preguntaste esto no te entendí muy bien, pero ahora parece estar bastante más claro, a ver si esta vez he acertado... :
Values = Array(Null , _
1773, 1773, 1773, 1773, _
1774, 1774, 1774, 1774, 1774, 1774, 1774, _
1775, 1775, 1775, 1775, 1775, 1775, 1775, _
"etc..." )
Set FSO = CreateObject ("Scripting.FileSystemObject" )
Set Files = FSO.GetFolder(".\" ).Files
For Each File in Files
If LCase(FSO.GetExtensionName(File)) = LCase("T01" ) Then
Wscript.Echo "File: " & File.name & _
VBNewLine & _
"Value: " & Values(Cint(Mid(File.name, 5, 3)))
End If
Next
Wscript.Quit(0)
Saludos
7359
Programación / .NET (C#, VB.NET, ASP) / Re: Ayuda con consulta noob de C#.
en: 3 Abril 2014, 09:37 am
Ya te dieron una solución rápida, pero ya puestos a introducir valores de un tipo específico... hagámoslo lo mejor posible!
VIDEO Friend Module Test
Friend Num As Integer = - 0I
Friend Sub Main( )
Console.Title = "Introduciendo valores... By Elektro"
Console.WriteLine ( )
Num = ReadNumber( Of Integer ) (
MaxValue:= Integer .MaxValue ,
Mask:= "." c,
CommentFormat:= "[+] Introduce un valor {0} :" ,
IndicatorFormat:= " >> " ,
DataTypeFormat:
= New Dictionary ( Of Type,
String ) From
{
{ GetType ( Integer ) ,
String .Format ( "entero (Int32 Max: {0})" , CStr ( Integer .MaxValue ) ) }
} )
Console.WriteLine ( Environment.NewLine )
Console.WriteLine ( String .Format ( "Valor {0}: {1}" , Num.GetType .Name , CStr ( Num) ) )
Console.ReadKey ( )
Environment.Exit ( 0 )
End Sub
' By Elektro
'
''' <summary>
''' Reads the console input to wait for an specific numeric value.
''' </summary>
''' <typeparam name="T"></typeparam>
''' <param name="MaxValue">Indicates the maximum value to expect.</param>
''' <param name="Mask">Indicates the character mask.</param>
''' <param name="CommentFormat">Indicates a comment string format.</param>
''' <param name="IndicatorFormat">Indicates a value indicator string format.</param>
''' <param name="DataTypeFormat">Indicates a data type string format.</param>
Friend Function ReadNumber( Of T) ( Optional ByVal MaxValue As Object = - 0S,
Optional ByVal Mask As Char = "" ,
Optional ByVal CommentFormat As String = "" ,
Optional ByVal IndicatorFormat As String = "" ,
Optional ByVal DataTypeFormat
As Dictionary ( Of Type,
String ) = Nothing ) As T
' A temporal string that stores the value.
Dim TmpString As String = String .Empty
' Stores the current typed character.
Dim CurrentKey As New ConsoleKeyInfo( "" , ConsoleKey.NoName , False , False , False )
' Retrieve the numeric object Type.
Dim DataType As Type = GetType ( T)
' Retrieve the Type name.
Dim ValueFormat As String = DataType.Name
' Retrieve the Type converter.
Dim Converter As System.ComponentModel .TypeConverter =
System.ComponentModel .TypeDescriptor .GetConverter ( DataType)
' Set the maximum number value.
If Not CBool ( MaxValue) Then
MaxValue = DataType.GetField ( "MaxValue" ) .GetValue ( Nothing )
End If
' Set the maximum number length.
Dim MaxValueLength As Integer = CStr ( MaxValue) .Length
' Set the indicator length.
Dim IndicatorLength As Integer = IndicatorFormat.Length
' Set the datatype name format.
If DataTypeFormat IsNot Nothing Then
ValueFormat = DataTypeFormat( DataType)
End If
' Write the comment.
If Not String .IsNullOrEmpty ( CommentFormat) Then
Console.WriteLine ( String .Format ( CommentFormat, ValueFormat) )
Console.WriteLine ( )
End If
' Write the indicator.
If Not String .IsNullOrEmpty ( IndicatorFormat) Then
Console.Write ( IndicatorFormat)
End If
' Write the value mask.
For X As Integer = 0 To MaxValueLength - 1
Console.Write ( Mask)
Next
' Set the cursor at the start of the mask.
Console.SetCursorPosition ( Console.CursorLeft - MaxValueLength, Console.CursorTop )
' Ready to parse characters!
Do
CurrentKey = Console.ReadKey ( True )
Select Case CurrentKey.Key
Case ConsoleKey.Enter ' Accept the input.
Exit Do
Case ConsoleKey.Backspace ' Delete the last written character.
If Not String .IsNullOrEmpty ( TmpString) Then
Console.SetCursorPosition ( Console.CursorLeft - 1 , Console.CursorTop )
Console.Write ( Mask)
Console.SetCursorPosition ( Console.CursorLeft - 1 , Console.CursorTop )
TmpString = TmpString.ToString .Substring ( 0 , TmpString.ToString .Length - 1 )
End If
Case ConsoleKey.LeftArrow ' Move 1 cell to Left.
' Not implemented yet (Too much work deleting character in the current cursor position).
' Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop)
Case ConsoleKey.RightArrow ' Move 1 cell to Right.
' Not implemented yet (Too much work deleting character in the current cursor position).
' Console.SetCursorPosition(Console.CursorLeft + 1, Console.CursorTop)
Case Else ' Another key
Dim NextValue As String = If ( Not String .IsNullOrEmpty ( TmpString) ,
TmpString.ToString & CurrentKey.KeyChar ,
CurrentKey.KeyChar )
' If value is valid and also does not exceed the maximum value then...
If Converter.IsValid ( NextValue) _
AndAlso Not NextValue > MaxValue _
AndAlso Not NextValue.Length > MaxValueLength Then
TmpString = NextValue
Console.Write ( CurrentKey.KeyChar )
End If
End Select
Loop
If Not String .IsNullOrEmpty ( TmpString) Then ' Return the value.
Return Converter.ConvertFromString ( TmpString)
Else
Return Nothing
End If
End Function
End Module
Traducción al vuelo a C# (no lo he testeado):
using Microsoft.VisualBasic ;
using System ;
using System.Collections ;
using System.Collections.Generic ;
using System.Data ;
using System.Diagnostics ;
static internal class Test
{
static internal int Num = - 0 ;
static internal void Main( )
{
Console. Title = "Introduciendo valores... By Elektro" ;
Console. WriteLine ( ) ;
Num
= ReadNumber
< int > ( MaxValue
: int . MaxValue , Mask
: '.' , CommentFormat
: "[+] Introduce un valor {0} :" , IndicatorFormat
: " >> " , DataTypeFormat
: new Dictionary
< Type,
string > { { string . Format ( "entero (Int32 Max: {0})" , Convert. ToString ( int . MaxValue ) )
} } ) ;
Console. WriteLine ( Environment. NewLine ) ;
Console. WriteLine ( string . Format ( "Valor {0}: {1}" , Num. GetType . Name , Convert. ToString ( Num) ) ) ;
Console. ReadKey ( ) ;
Environment. Exit ( 0 ) ;
}
/// <summary>
/// Reads the console input to wait for an specific numeric value.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="MaxValue">Indicates the maximum value to expect.</param>
/// <param name="Mask">Indicates the character mask.</param>
/// <param name="CommentFormat">Indicates a comment string format.</param>
/// <param name="IndicatorFormat">Indicates a value indicator string format.</param>
/// <param name="DataTypeFormat">Indicates a data type string format.</param>
static internal T ReadNumber< T> ( object MaxValue = - 0 , char Mask = "" , string CommentFormat = "" , string IndicatorFormat = "" , Dictionary< Type, string > DataTypeFormat = null )
{
// A temporal string that stores the value.
string TmpString = string . Empty ;
// Stores the current typed character.
ConsoleKeyInfo CurrentKey
= new ConsoleKeyInfo
( "" , ConsoleKey
. NoName ,
false ,
false ,
false ) ;
// Retrieve the numeric object Type.
// Retrieve the Type name.
string ValueFormat = DataType. Name ;
// Retrieve the Type converter.
System.ComponentModel . TypeConverter Converter = System.ComponentModel . TypeDescriptor . GetConverter ( DataType) ;
// Set the maximum number value.
if ( ! Convert. ToBoolean ( MaxValue) ) {
MaxValue = DataType. GetField ( "MaxValue" ) . GetValue ( null ) ;
}
// Set the maximum number length.
int MaxValueLength = Convert. ToString ( MaxValue) . Length ;
// Set the indicator length.
int IndicatorLength = IndicatorFormat. Length ;
// Set the datatype name format.
if ( DataTypeFormat != null ) {
ValueFormat = DataTypeFormat( DataType) ;
}
// Write the comment.
if ( ! string . IsNullOrEmpty ( CommentFormat) ) {
Console. WriteLine ( string . Format ( CommentFormat, ValueFormat) ) ;
Console. WriteLine ( ) ;
}
// Write the indicator.
if ( ! string . IsNullOrEmpty ( IndicatorFormat) ) {
Console. Write ( IndicatorFormat) ;
}
// Write the value mask.
for ( int X = 0 ; X <= MaxValueLength - 1 ; X++ ) {
Console. Write ( Mask) ;
}
// Set the cursor at the start of the mask.
Console. SetCursorPosition ( Console. CursorLeft - MaxValueLength, Console. CursorTop ) ;
// Ready to parse characters!
do {
CurrentKey = Console. ReadKey ( true ) ;
switch ( CurrentKey. Key ) {
case ConsoleKey. Enter :
// Accept the input.
break ; // TODO: might not be correct. Was : Exit Do
break ;
case ConsoleKey. Backspace :
// Delete the last written character.
if ( ! string . IsNullOrEmpty ( TmpString) ) {
Console. SetCursorPosition ( Console. CursorLeft - 1 , Console. CursorTop ) ;
Console. Write ( Mask) ;
Console. SetCursorPosition ( Console. CursorLeft - 1 , Console. CursorTop ) ;
TmpString = TmpString. ToString . Substring ( 0 , TmpString. ToString . Length - 1 ) ;
}
break ;
case ConsoleKey. LeftArrow :
// Move 1 cell to Left.
break ;
// Not implemented yet (Too much work deleting character in the current cursor position).
// Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop)
case ConsoleKey. RightArrow :
// Move 1 cell to Right.
break ;
// Not implemented yet (Too much work deleting character in the current cursor position).
// Console.SetCursorPosition(Console.CursorLeft + 1, Console.CursorTop)
default :
// Another key
string NextValue = ! string . IsNullOrEmpty ( TmpString) ? TmpString. ToString + CurrentKey. KeyChar : CurrentKey. KeyChar ;
// If value is valid and also does not exceed the maximum value then...
if ( Converter. IsValid ( NextValue) && ! ( NextValue > MaxValue) && ! ( NextValue. Length > MaxValueLength) ) {
TmpString = NextValue;
Console. Write ( CurrentKey. KeyChar ) ;
}
break ;
}
} while ( true ) ;
// Return the value.
if ( ! string . IsNullOrEmpty ( TmpString) ) {
return Converter. ConvertFromString ( TmpString) ;
} else {
return null ;
}
}
}
//=======================================================
//Service provided by Telerik (www.telerik.com)
//Conversion powered by NRefactory.
//Twitter: @telerik
//Facebook: facebook.com/telerik
//=======================================================
7360
Programación / Scripting / Re: [Batch] Arrastrar Y Desplazar
en: 2 Abril 2014, 16:30 pm
Pues si quieres mi opinión, integrar una característica Drag&Drop en VB.Net /C-Sharp resulta algo muy sencillo, cómodo y eficiente, ya que proporciona classes específicas para dichas acciones y determinar el tipo de elemento que se arrastró (archivo, carpeta, texto, imagen, etc..) cosa que no he visto que tengan otros lenguajes más simples (Scripting) aunque tambien resulta algo sencillo. PD: No ofrezco ayuda por privado, en el post de arriba tienes todo lo necesario y un ejemplo completo en Batch, debes aprender lo básico del lenguaje que pretendas usar... saludos!