Hot Topic (More than 10 Replies) @SpecCommand() (Read 2320 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
@SpecCommand()
Sep 29th, 2011 at 7:56pm
Print Post Print Post  
I'm trying to use the @SpecCommand to export a set of data from my file.  The spec is saved as "All Data".

I've tried the following programming and it won't successfully pass the "test" function.

Please suggest what i'm doing wrong.

Thanks!

Var vRt as String

vRt=@SpecCommand(Spec_Operation_Run,Spec_Type_Export,"All Data")
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SpecCommand()
Reply #1 - Sep 29th, 2011 at 9:28pm
Print Post Print Post  
Are you including the "sbasic_include.sbas" file?

BTW: When using constants, it is traditional for them to be in all caps to make it clear that they are constants as opposed to variables:

Code
Select All
#include "sbasic_include.sbas"

Var vRt as String

vRt = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_EXPORT, "All Data")
 

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: @SpecCommand()
Reply #2 - Oct 3rd, 2011 at 1:33pm
Print Post Print Post  
You're right, I didn't include the sbasic_include" statement.

However, when I added the statement, nothing changed.  I still don't get any action when i run the programming.   I copied your suggestion (below).  Any thoughts as to why this isn't working?

Please advise and thanks for your help.


#include "sbasic_include.sbas"

Var vRt as String

vRt = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_EXPORT, "All Data")


  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SpecCommand()
Reply #3 - Oct 3rd, 2011 at 1:39pm
Print Post Print Post  
My suggestion about the case of constants is purely for human reader clarity, doesn't change how anything functions.

After you clear away any syntax errors, you will have to use debugging techniques to determine any runtime errors. Are any of the error routines (@error and friends) being set? Have you placed any "writeln" statements in your code to make sure that it is executing the portions portrayed? Have you double checked the spec names used?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: @SpecCommand()
Reply #4 - Oct 3rd, 2011 at 2:23pm
Print Post Print Post  
Yes, I've used WriteLn statements before and after the command to make sure the program was reaching it.  I've also verified the saved spec name (several times).  I've never used @error before, so my latest attempt was per the programming below.  When I click the command button, I get the two statements, but no activity occurs.

Thoughts?


Var vRt as String

#include "sbasic_include.sbas"

WriteLN("About to Start")

vRt = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_EXPORT, "All Data")
If @error
{
     @Msg("Have a problem!")
}

Writeln("Made it to this point")

  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @SpecCommand()
Reply #5 - Oct 3rd, 2011 at 2:30pm
Print Post Print Post  
Are you absolutely sure that you have an Export Spec named "All Data" exactly as it's spelled in your code?

When you run this command, are you in Update mode with a batch of records retrieved?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @SpecCommand()
Reply #6 - Oct 3rd, 2011 at 2:43pm
Print Post Print Post  
NHUser wrote on Oct 3rd, 2011 at 2:23pm:
Yes, I've used WriteLn statements before and after the command to make sure the program was reaching it.  I've also verified the saved spec name (several times).  I've never used @error before, so my latest attempt was per the programming below.  When I click the command button, I get the two statements, but no activity occurs.

Thoughts?


Var vRt as String

#include "sbasic_include.sbas"

WriteLN("About to Start")

vRt = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_EXPORT, "All Data")
If @error
{
     @Msg("Have a problem!")
}

Writeln("Made it to this point")



The @SpecCommand to run an export requires more arguments:
filename
custom separator
custom delimiter
tabbed
custom
no separator
ignore fixed
all
none
header

These correspond to the fields in the export dialog and the RunExportSpec command.

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: @SpecCommand()
Reply #7 - Oct 3rd, 2011 at 2:57pm
Print Post Print Post  
None of the documentation shows how to add these options.  Would you send me an example of what the programming should look like?

Thanks!

  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @SpecCommand()
Reply #8 - Oct 3rd, 2011 at 3:11pm
Print Post Print Post  
This is entirely our fault, Paul. The documentation for this command is beyond insufficient and we're going to take care of that. Meanwhile, here is an example of how to do this. The arguments match those used by RunExportSpec, so you can look at that command for full documentation of the options. Note that you must load the named spec before running it.

Code
Select All
#include "sbasic_include.sbas"

var vRt as String

/*
Arguments:
filename
custom seperator character
custom delimiter character
tabbed
use custom sep
no sep
ignore fixed
all
none
use custom delim
header
*/

	vRt = @SpecCommand(SPEC_OPERATION_LOAD, SPEC_TYPE_EXPORT, "All Data")
	vRt = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_EXPORT, "myfile.txt", ";", "", "0", "1", "0", "1", "0", "1", "0", "0")  





  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: @SpecCommand()
Reply #9 - Oct 3rd, 2011 at 5:40pm
Print Post Print Post  
I think I've got it working.

Thanks for the help!
  
Back to top
 
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: @SpecCommand()
Reply #10 - Jan 9th, 2012 at 7:11pm
Print Post Print Post  
Hello!

can i use this Code?

The vSearchParam is a variable date periode

vStr = @SpecCommand(SPEC_OPERATION_CLEAR, SPEC_TYPE_RETRIEVE, "")
vStr = @SpecCommand(SPEC_OPERATION_LOAD, SPEC_TYPE_RETRIEVE, "Datum =" + vSearchParam)
vStr = @SpecCommand(SPEC_OPERATION_RUN, SPEC_TYPE_RETRIEVE, "")

thank you for the help.
Dr. Belhareth
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: @SpecCommand()
Reply #11 - Jan 10th, 2012 at 3:45am
Print Post Print Post  
Amor wrote on Jan 9th, 2012 at 7:11pm:
vStr = @SpecCommand(SPEC_OPERATION_LOAD, SPEC_TYPE_RETRIEVE, "Datum =" + vSearchParam)

I think you misunderstand how this line us supposed to be used. The last parameter should be the name of a saved retrieve spec, not the name of an LE and the value you want inserted into it.

If you simply want to insert a value into one of the LEs, then use:
Code
Select All
vStr = @SpecCommand(SPEC_OPERATION_SET, SPEC_TYPE_RETRIEVE, "Datum =" + vSearchParam) 


You can also insert values into multiple LEs like this:
Code
Select All
vStr = @SpecCommand(SPEC_OPERATION_SET, SPEC_TYPE_RETRIEVE, "Datum =" + vSearchParam, "LE2=" + vSearchParam2, "LE3=m..", LE4=s..") 


Alternatively, you could also use FormFieldValue to assign values, like this:
Code
Select All
FormFieldValue(@Layout, "Datum", 0, vSearchParam) 


  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Roberto
Member
*
Offline



Posts: 3
Joined: Oct 1st, 2014
Re: @SpecCommand()
Reply #12 - Oct 12th, 2014 at 12:55pm
Print Post Print Post  
Hi there, I´m just a starter.
I would like to copy all the records from form1 to form2 using a command botton and then delete all records in form1. Idid this:
#include "sbasic_include.sbas"

var vMenu as string
var vMenu1 as Int
var vRun as Int
var vRt as String

vMenu1 = @SelectTreeItem(@Application + "!Forms!Search/Update!form1!form1")

@Macro("C:\sesame2\Data\openform1.mac")
//this macro retrieve records of form1
ClearMacro()

vMenu = @SelectTreeItem(@Application + "!Forms!Search/Update!form2!form2")
@Macro("C:\sesame2\Data\saveprsoldout.mac")
//this macro retrieve records of form2
ClearMacro()

vRt = @SpecCommand(SPEC_OPERATION_LOAD, SPEC_TYPE_COPY, "LTOSOLD")
      
If @Mode() = 1
{
  vRun = @LoadCopySpec("LTOSOLD")
  If vRun = 1
  {
   RunCopySpec()
  }
}
When I click on the botton I can see that I cannot load the "LTOSOLD" copy spec.

Any advice?

Thanks in advance.
Roberto Ferrario









@save
@exit

  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: @SpecCommand()
Reply #13 - Nov 7th, 2014 at 7:02pm
Print Post Print Post  
For starters, you should avoid using macros if possible. You can do almost anything in Sesame with programming. In all the things I've done with Sesame, I only use macros for one specific purpose which can't be programmed, and even then I write the macro in code on-the-fly, then write it to disk just before calling it.

You need to use a ClientLocalValue as a flag before opening another form, so that once the other form opens, you can check for the state of that ClientLocalValue with a conditional statement.

Here's a rough example of this technique.

This is code from a command button on my Main Menu form:
Code
Select All
var vNav as Int

If (@FormResultSetTotal("Invoice:(Add)") = -1) and (@FormResultSetTotal("Invoice:(Search)") = -1) and (@FormResultSetTotal("Invoice:(Update)") = -1)
{
	ClientLocalValue("Billables", 1)
	vNav = @SelectTreeItem(@Application + "!Forms!Search/Update!Invoice!Invoice")
}
Else
	@MsgBox("All the Invoice tabs must be closed to view Billables.", "", "Close the tabs, and select Billables again.")
 



This is code in the Invoice :: On Retrieve Spec Open event:
Code
Select All
// Reset the flag if previous run did not find any records to retrieve and left the flag set,
// because the flag normally doesn't get reset until the "Invoice :: On Form Entry" event.
if @ClientLocalValue("Billables") = 2
	ClientLocalValue("Billables", 0)

if @ClientLocalValue("Billables") = 1
{
	ClientLocalValue("Billables", 2)
	vNav = @LoadRetrieveSpec("Billables")
	vNav = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")
}
 



This is code in the Invoice :: On Form Entry:
Code
Select All
if @ClientLocalValue("Billables") = 2 and @Update
{
	ClientLocalValue("Billables", 0)
	// Load and run specs, etc.
}
 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged