Macro syntax failure in attachmate extra - macros

I've been scrubbing google to find a quick reference for macro coding in Attachmate extra! unsuccessfully. Could someone point me to a URL to learn what I need to know, tell me how to resolve the code below or both.
I took a "Hello World" example and a recorded macro and mushed the below code together, which does what i need with a couple exceptions.
Dim dlgHello as HelloDialog 'Declare the dialog file.
nRet = Dialog (dlgHello)
Select Case nRet 'dlgHello.AllButtons
Case - 1 ' OKButton
Sess0. Screen. Sendkeys ("Show a60:4aug;a")
Sess0. Screen. Sendkeys("<Enter>")
Sess0. Screen.WaitHostQuiet (g HostSettleTime)
System. Timeoutvalue = OldsystemTimeout
Msabox "Done"
Case 0 ' CancelButton
Msgbox "Goodbye! "
End Select
While this code above works, I need to change it to pull system date and subtract two days.
Original code Sess0. Screen. Sendkeys ("Show a60:4aug;a")
Instead of the static 4aug, I need the code to pull the system date then subtract two days.
My failed attempt was Sess0. Screen. Sendkeys ("Show a60:"Today() -2"a")
Would be grateful if anyone could tell me how to resolve this and also point me to a good learning resource. Thanks

I received a working solution from Tom F in the MicroFocus community. Solution below.
Sub Main
Dim myDate
myDate=CVar(Date)-2
myDate = Format(myDate, "dmmm")
End Sub
https://portal.microfocus.com/s/article/KM000008384?language=en_US

Related

how to write a text and calculation in a same time like Calcnote app in Flutter

I try lots of things but I failed kindly help me with how to do this and please someone shares a complete. I also share a screenshot of the original app I making same like this app.
App description:
1:When typing or calculating on the app if the user needs the next line and show a list num
2: The most important thing is when we calculate any num can we write something in the same type ( you think it's a notepad + calculator)?
3: Also when we write and type 5 + 5 we don't need to press = equal to. they abstract and subtract automatically.
thank you so much for your support.

Qt Save form take 3-4 second to open

i'm using this on push button click in Qt:
QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"),
QString(),
tr("(*.csv));
it take 3-4 second to open the save Form. why? how i can improve speed?
Try to connect this slot to a QPushButton:
void MainWindow::openFD(){
QTime myopentime=QTime::currentTime();
for (int i=0;i<1000000;i++) ;//comment out this line for the real test
QString fileName = QFileDialog::getSaveFileName(this,QString(),QString(myopentime.toString("m.s.zzz")+" "+QTime::currentTime().toString("m.s.zzz"))
,tr("*.csv") );
}
Then try to run it with and without the count part.
You will see, that the count part adds some ms... without it there is not even ms (mili-second) of difference in the time shown in filename place.
So, you have to search somewhere else in your code or give us a better example.
PS:
1) You will need :
#include <QTime>
2) The line that counting is there to show you that my method works (since you will see some difference when uncomment)
Result and Answer: The problem is not on QFileDialog if this test will not give you differences but somewhere else in your code or possibly in the Window manager of your OS.

Override 'Cancel' in event procedures

There is data validation in my MS Word user form which returns the focus to the textbox where the user entered something incorrect. Now I am trying to accommodate the user's change of mind: instead of correcting the entry, I want him to be able to exit the form (click the Exit command button), in which case the entry would be discarded. I suppose that a solution would start with not using the text box's exit event. I little help from someone who knows the answer would save me a lot of testing time, perhaps to find out that I can't do it.
Does anyone know?
I understand that you are handling the Exit event of the Textbox, setting the Cancel output parameter if the data is not valid.
There's a tricky but simple solution that permits to keep that working and still have an Exit button. It permits to activate the handler of the Exit button without requiring the focus to leave the Textbox. This way you can unload the Form safely in this handler.
Try this it works pretty smoothly:
1- Set the property TakeFocusOnClick of the Exit command button to False. You can do that at design time in the property-sheet, or at run-time i.e. at UserForm_Activate
2- just unload the form when the Exit button is clicked:
Private Sub ExitButton_Click()
Unload Me
End Sub
#A.S.H provided the key to the solution below. His point is that it is possible to call another event procedure while Cancel is active in the Exit procedure of a control. That other procedure can be used to rectify the condition in the first control which is triggering the Cancel, thereby enabling an orderly exit. The all-enabling condition is that the control on whose click event the rectifying procedure is to run must not take the focus when clicked (meaning it can run without triggering an exit from the control stuck on Cancel). I have added code to the exit procedure to set CmdExit.TakeFocusOnClick = False when a Cancel condition arises there. Now, ...
Private Sub CmdExit_Click()
' 12 May 2017
' if CmdExit can't take the focus it can't be the ActiveControl
If Not ActiveControl Is CmdExit Then
Select Case ActiveControl.Name
Case "Cbx107"
Cbx107.Value = ""
Case "Tbx53"
Tbx53.Value = "0"
End Select
With CmdExit
If Not .TakeFocusOnClick Then
.TakeFocusOnClick = True
.SetFocus
End If
End With
End If
' now CmdExit is the ActiveControl
MsgMe "Cmd Exit: ActiveControl = " & ActiveControl.Name
Me.Hide
End Sub

Some beginner questions

I guess I'll start by saying I am very new to B4A, and to programming in general. I have some very basic java and html exp. but that's it. I do not have any basic4ppc or really any IDE experience. Been using B4A for a few days now and can't get over the hump. Here are my noob questions:
Does having many activities (20-30+) slow down the app? Is there a downside to having a lot of activities?
I can't figure out how to scroll in the designer. I am trying to make a screen that has 25 buttons down in 1 column. However I can't scroll down to add more buttons below. I am able to add buttons programmically and in the fashion that I want (using a for loop), but is it normal to create views at runtime like this?
How do you ensure your app looks the same across all devices? Tablets? I have a scroll view that fits perfect in the emulator, but on my phone (droid x), the bottom of the scroll view is not stretched to the bottom of the phone. I use the code: scvScreen1.Initialize(100%y). Is that not right?
I have a Email screen in which is comprised of an edittext and a Send button, so that the users can send me questions from the app. However the Send button gives me this error on the 'URI =' line: "LastException java.lang.NumberFormatException: mailto:" here is the code:
Sub btnSendEmail_Click
Dim Uri As String
Uri="mailto:me#gmail.com?subject=Test Email&body=" + edtHelpEmail.Text
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW,Uri
StartActivity(Intent1)
End Sub
Or is there another way to open the device's default email program?
Regarding last question, how do I copy error messages to clipboard?? I selected the red error message on the bottom right of the IDE and tried ctrl-c, but didn't work.
In B4A, what is a good method of storing persistent data? All I really need to store are some strings. Nothing fancy. These strings are to be stored locally. AI made this easy by using TinyDB.
When using the designer, how do you ensure your views are centered on all devices? For instance, I have a screen that has several rows made up of: (label, edittext, label). And I want each row to be center aligned. Do I do this programmically? I'm thinking I would have to append each row of (label, edittext, label) to a panel, then in the code center the panel. Is this correct?
That's all I got for now, but I'm sure there will be plenty more questions later.
1) The whole idea of android is to small components i.e. Apps working together, so no need to worry about opening lots of activities. Memory is very well managed behind the scenes in Android.
2) Sure. That sounds fine to me. Use the Layout designer as much as you can and then add the dynamic stuff later. It's all about striking a balance between the size of your code and the number of activities.
3) In the Designer there's an option called 'Send to UI Cloud'. This compares your app over multiple screen sizes. You can also scale your design and programmatically resize specific controls within your app in the Activity_Create Lifecycle
4) What you're doing is almost correct. I corrected your code:
Sub MailTo(StrAddress As String, StrSubject As String, StrBody As String)
Dim StrMethod As String = "Sub MailTo(StrAddress As String, StrSubject As String, StrBody As String)"
Try
Dim StrUri As String
StrUri = "mailto:" & StrAddress & "?subject=" & StrSubject & "&body=" & StrBody
Dim Intent As Intent
Intent.Initialize(Intent.ACTION_VIEW, StrUri)
StartActivity(Intent)
Catch
If BlnLoudExceptions Then CdException.Show(StrClass, StrMethod, LastException)
End Try
End Sub
I tend to have a code module called CdIntent.bas for these functions as it both keeps the project organised and makes it easier to implement the same functionality across projects.
Then to call you would use
CdIntent.MailTo("me#yes.no", "Subject!", "Body!")
5) I have a file called CdException.bas
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Show(StrClass As String, StrMethod As String, Ex As Exception)
LogColor("Exception: " & Ex.Message & " - Class: " & StrClass & " - Method: " & StrMethod, Colors.Magenta)
End Sub
and then wrap functions in the following way:
Sub FunctionName(...Parameters...) as Int
Dim StrMethod As String = "Sub Sleep(LngMilliseconds As Long)"
Dim IntResult As Int = 0
Try
[code here inc. IntResult = ???]
Catch
If BlnLoudExceptions Then CdException.Show(StrClass, StrMethod, LastException)
End Try
Return IntResult
End Sub
BlnLoudExceptions is a global boolean that you'd declare in
Process_Globals that you can switch on an off exception logs.
StrClass is a global String that you'd declare in Process_Globals
that contains the name of the class e.g. "CdIntent.bas"
The exceptions then appear in magenta in the log screen along with the method name and class in which they occurred allowing you to home in on them.
6) I have a table in an SQLLite database called TabletSettings, which has two TEXT colums called 'Name' and 'Value'. It works well and gets you into a (what I think is a) good habit of always having a database available to your app from the get-go.
7) I'll get back to you on this as I haven't done this before.
Until then, the following thread will help you in the B4A forum http://www.basic4ppc.com/android/forum/threads/convert-integer-to-dip.18800/
I agree with Jim's point but will attempt to answer 1.
I'm new to android myself but as I understand it activities on the whole are only running when active. Unless you are using the app to continuously do something there is only one activity at a time. The number of activities is likely to affect the ram available more than anything. Lastly it might be worth walking first rather than running so to speak but trying a single and then add multiple activities.
You could try adding a ListView or ScrollView where the items are the buttons, this seems to be the std way of doing things otherwise a tabbed view.

Color coding tasks in a Microsoft Project Macro

This seems like it should be straight forward, but I'm seeing some strange behavior. I'm attempting to color code my tasks based on a flag. It appears to be correctly coloring the tasks, but at some point in the processing the initial tasks that were colored are getting reset to black. The task that it happens on seems to be fairly inconsistent too. Here's how I'm trying to perform this task (simplified to it's barest form):
Sub ColorTasks()
Dim t As Task
For Each t In ActiveProject.Tasks
SelectRow t.ID, RowRelative:=False
Font32Ex Color:=2366701
Next
End Sub
This code seems to work just fine for smaller data sets, but this project contains around 2,000 tasks. Any ideas?
Yes I too am having a similar problem::
For Each t In tsks
Select Case t.Text1
Case "COMPLETE"
SelectRow Row:=t.ID, RowRelative:=False
Font32Ex CellColor:=&659B59
Case "NOT STARTED"
SelectRow Row:=t.ID, RowRelative:=False
Font32Ex CellColor:=&862525
Case "IN PROGRESS"
SelectRow Row:=t.ID, RowRelative:=False
Font32Ex CellColor:=&3A3AD4
End Select
Next t
According to: http://msdn.microsoft.com/en-us/library/ff863572.aspx this should work, yet I get syntax errors every time. Only way I can get this to work is if I use the FontEx method which limits me to only 16 colors....
I know that this is an old question but I hope it may be useful for someone with similar problem.
The mistake is that you've forgotten to add 'H' before hexadecimal number, so properly there should be:
Font32Ex CellColor:=&H3A3AD4
etc
I find it easier to use RGB values.
Font32Ex CellColor:=RGB(255, 199, 206) 'Changes fill
Font32Ex Color:=RGB(156, 0, 6) ' Changes font color
Using your code, I turned my entire sheet to red on pink, 350 tasks. I don't have a means to test it on 2000 though without a lot of extra work.