Come moltiplicare l'input dell'utente per un numero costante?Tutti,
Sto cercando di moltiplicare il numero di input dell'utente per una costante. Devo utilizzare il numero finale (hoursBack) come parte di un indirizzo web.
local(
{Name= "ABCD", daysBack = "7", formError = 1, rv},
While( formError > 0,
formError = 0;
rv = Dialog(
Title( "Select Extract criteria" ),
VList(
HList( "Name:", Name= EditText( Name) ),
HList( "Days Back", daysBack = EditText( daysBack ) ),
HList( Button( "OK" ), Button( "Cancel" ) )
)
);
If( rv["button"] < 0,
Throw( "Bye!" )
);
Name= rv["Name"];
If( Name== "",
formError
++);
daysBack = rv["daysBack"];
If( daysBack == "",
formError
++);
If( formError > 0,
Dialog( "Missing required form input values" )
);
);
Write( "Name=" || Name);
hoursBack = daysBack*24; //Getting an error here
Status Msg( "Extracting data for " || Name);
dt = queryData( "Newtable", hoursBack, Name); //Query data function is defined in a different part of the code
);Ottenere il seguente errore -
Impossibile convertire l'argomento in un numero [o una matrice] nell'accesso o nella valutazione di "Moltiplica", daysBack * / * ### * / 24 / * ### * /
ScriptingRi: Come moltiplicare l'input dell'utente per un numero costante?num (daysback) * 24
ti farà superare il problema in cui daysback contiene una stringa.
Ri: Come moltiplicare l'input dell'utente per un numero costante?Il problema è che stai immettendo daysBack da un campo EditText (), che restituisce una stringa di caratteri, non un valore numerico.Quindi deve essere convertito.Vedi il mio codice qui sotto
local(
{Name= "ABCD", daysBack = "7", formError = 1, rv},
While( formError > 0,
formError = 0;
rv = Dialog(
Title( "Select Extract criteria" ),
VList(
HList( "Name:", Name= EditText( Name) ),
HList( "Days Back", daysBack = EditText( daysBack ) ),
HList( Button( "OK" ), Button( "Cancel" ) )
)
);
If( rv["button"] < 0,
Throw( "Bye!" )
);
Name= rv["Name"];
If( Name== "",
formError
++);
daysBack = num(rv["daysBack"]);show(daysback);
If( daysBack == "",
formError
++);
If( formError > 0,
Dialog( "Missing required form input values" )
);
);
Write( "Name=" || Name);
hoursBack = daysBack*24;
show("xx",hoursback) ; //Getting an error here
Status Msg( "Extracting data for " || char(Name));
dt = queryData( "Newtable", hoursBack, Name); //Query data function is defined in a different part of the code
);Ri: Come moltiplicare l'input dell'utente per un numero costante?@txnelson Grazie. Ho provato quello che hai suggerito ma ricevo un errore. Ho allegato l'istantanea dell'errore