Mostrando entradas con la etiqueta programming. Mostrar todas las entradas
Mostrando entradas con la etiqueta programming. Mostrar todas las entradas

domingo, 7 de mayo de 2017

(Swift3.0) Enviar datos entre ViewControllers usando Segue




Se crea el proyecto



Se agrega un nuevo view controller



Se agrega un textField al primer view controller


Añadir constrains para el textField



Agregar un label en el viewController2


Se agregan 2 botones



Se crea un nuevo archivo




Relacionamos la clase con el segundo Viewcontroller




Conectamos el textField con el código de ese viewcontroller


Hacemos lo mismo con el botón



Boton "back" en el segundo view controller


para el label


Se le asigna un nombre a la unión entre views


Se cambio el nombre ViewController por LoginVC, se selecciona el circulo amarillo de ese view y se elige la clase




loginVC.swift



SecondVC.swift



 Ahora al escribir un nombre, nos redirige al secondVC con el nombre y cambia el color a amarillo 
























jueves, 9 de junio de 2016

run a python script from another python script

Short Post*

To open another script from a script the following comand could be works
 In this case, the script will execute it 6 times, change the number in while 


import subprocess
cmd = 'python script.py'
i=0

while i < 6:
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
    out, err = p.communicate()
    result = out.split('\n')
    for lin in result:
        if not lin.startswith('#'):
        print(lin)
    i = i + 1


martes, 31 de mayo de 2016

Pasar varias variables con GET en php


Para pasar una sola variable desde un archivo php a otro se puede aplicar el siguiente ejemplo.

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <title>Form</title>
</head>
<body>
    <form action="get.php" method="get">
        <input type="text" name="firstname" /><br/>
        <input type="text" name="lastname" /><br/>
        <input type="submit" value="send" /> 
    </form>
</body>
</html>
<?php
if(isset($_GET['firstname']) && isset($_GET['lastname']))
{
    echo $_GET['firstname'];
    echo "<br />";
    echo $_GET['lastname'];
}?>


Otra manera de pasar una o mas variables sin usar formularios es la siguiente:

a) pagina de envió


<html>
  <head>
     <title>Titulo pagina envio</title> 
  </head>
<body>
    <h1>Envío de variables a otra página.</h1>
    <?php  
    $a="Hola, ";
    $b="bienvenido a mi página";
    echo "Enviar las siguientes variables:<br/>";
    echo "\$var1 = $var1 <br/>";
    echo "\$var2 = $var2 <br/>";
    ?>
   //se pulsa este boton para enviar las variables
   <?php echo "<a href='destino.php?a=$a&b=$b'>Enviar variables</a>"; ?>
</body>
</html>


b) pagina de destino




<html>
<head>
<title>Titulo pagina de destino</title> 
</head>
<body>
<h1>Al abrir esta página se han pasado las siguientes variables:</h1>
<?php  
$var1=$_GET['var1'];
$var2=$_GET['var2'];
echo "variable1  $var1";
echo "variable2  $var2";
?>
</body>
</html>